Search in sources :

Example 6 with MechModel

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

the class FemModel3dEditor method addActions.

public void addActions(EditActionMap actions, SelectionManager selManager) {
    LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
    if (containsSingleSelection(selection, FemModel3d.class)) {
        FemModel3d model = (FemModel3d) selection.get(0);
        actions.add(this, "Add FemMarkers ...", EXCLUSIVE);
        actions.add(this, "Rebuild surface mesh");
        actions.add(this, "Add new surface mesh");
        actions.add(this, "Save surface mesh ...");
        actions.add(this, "Save mesh as Ansys file...");
        if (model.getGrandParent() instanceof MechModel) {
            actions.add(this, "Attach particles ...", EXCLUSIVE);
        }
    } else if (containsMultipleCommonParentSelection(selection, HexElement.class)) {
        actions.add(this, "Subdivide elements");
    }
    if (containsMultipleCommonParentSelection(selection, FemElement3d.class)) {
        actions.add(this, "Rebuild surface mesh for selected elements");
        actions.add(this, "Add new surface mesh for selected elements");
    }
}
Also used : HexElement(artisynth.core.femmodels.HexElement) MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 7 with MechModel

use of artisynth.core.mechmodels.MechModel 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 8 with MechModel

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

the class MeshBodyEditor method addActions.

public void addActions(EditActionMap actions, SelectionManager selManager) {
    LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
    if (containsMultipleSelection(selection, MeshComponent.class)) {
        if (containsSingleSelection(selection, MeshComponent.class)) {
            MeshComponent body = (MeshComponent) selection.get(0);
            actions.add(this, "Save local mesh as ...");
            actions.add(this, "Save world mesh as ...");
            if (body.getMesh() instanceof PolygonalMesh && body.getGrandParent() instanceof MechModel) {
                actions.add(this, "Add mesh inspector");
            }
        }
    }
}
Also used : MeshComponent(artisynth.core.mechmodels.MeshComponent) MechModel(artisynth.core.mechmodels.MechModel) PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 9 with MechModel

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

the class RigidBodyEditor method applyAction.

public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
    if (containsMultipleSelection(selection, RigidBody.class)) {
        if (actionCommand == "Select markers") {
            LinkedList<ModelComponent> list = (LinkedList<ModelComponent>) selection.clone();
            for (ModelComponent c : list) {
                FrameMarker[] mkrs = ((RigidBody) c).getFrameMarkers();
                for (int i = 0; i < mkrs.length; i++) {
                    myMain.getSelectionManager().addSelected(mkrs[i]);
                }
                myMain.getSelectionManager().removeSelected(c);
            }
        }
        if (containsSingleSelection(selection, RigidBody.class)) {
            if (actionCommand == "Edit geometry and inertia ...") {
                if (myEditManager.acquireEditLock()) {
                    RigidBody body = (RigidBody) selection.get(0);
                    RigidBodyGeometryAgent agent = new RigidBodyGeometryAgent(myMain, body);
                    agent.show(popupBounds);
                }
            } else if (actionCommand == "Save mesh as ...") {
                RigidBody body = (RigidBody) selection.get(0);
                PolygonalMesh mesh = body.getMesh();
                EditorUtils.saveMesh(mesh, mesh != null ? mesh.getMeshToWorld() : null);
            } else if (actionCommand == "Attach particles ...") {
                if (myEditManager.acquireEditLock()) {
                    RigidBody body = (RigidBody) selection.get(0);
                    // XXX should be more general than this ... what if mechModel
                    // is a sub model?
                    MechModel mech = (MechModel) body.getGrandParent();
                    myMain.getSelectionManager().clearSelections();
                    AttachParticleBodyAgent agent = new AttachParticleBodyAgent(myMain, mech, body);
                    agent.show(popupBounds);
                }
            } else if (actionCommand == "Add mesh inspector") {
                RigidBody body = (RigidBody) selection.get(0);
                MechModel mech = (MechModel) body.getGrandParent();
                EditablePolygonalMeshComp editMesh = new EditablePolygonalMeshComp(body.getSurfaceMesh());
                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 : MechModel(artisynth.core.mechmodels.MechModel) EditablePolygonalMeshComp(artisynth.core.renderables.EditablePolygonalMeshComp) FrameMarker(artisynth.core.mechmodels.FrameMarker) RigidBody(artisynth.core.mechmodels.RigidBody) PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 10 with MechModel

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

the class ForceTargetTerm method createForceJacobian.

private void createForceJacobian() {
    MechModel mechMod = (MechModel) myMech;
    SparseBlockMatrix GT = new SparseBlockMatrix();
    VectorNd dg = new VectorNd();
    mechMod.getBilateralConstraints(GT, dg);
    if (debug) {
        System.out.println("num con = " + mechMod.bodyConnectors().size());
        System.out.println(GT.colSize());
        System.out.println(GT.rowSize());
        System.out.println(GT.getSize());
        System.out.println(GT.numBlocks());
        System.out.println(GT.getBlock(0, 0));
        System.out.println(GT.getBlock(0, 1));
        System.out.println(GT.getBlock(0, 2));
        System.out.println(GT.getBlock(1, 0));
    }
    // find the number of bilateral constraints for each connector
    int[] connectorSizes = new int[mechMod.bodyConnectors().size()];
    int[] targetToConnectorMap = new int[myForceTargets.size()];
    int targetIdx = 0;
    for (ForceTarget ft : myForceTargets) {
        int connectorIdx = 0;
        for (BodyConnector connector : mechMod.bodyConnectors()) {
            if (debug) {
                System.out.println(connector.getName());
                System.out.println(ft.getName());
            }
            if (ft.getConnector() == connector) {
                targetToConnectorMap[targetIdx] = connectorIdx;
                targetIdx++;
            }
            if (connector.isEnabled() == true) {
                if (debug) {
                    System.out.println(connector.numBilateralConstraints());
                }
                connectorSizes[connectorIdx] = connector.numBilateralConstraints();
                connectorIdx++;
            }
        }
    }
    myForJacobian = new SparseBlockMatrix(new int[0], connectorSizes);
    for (int i = 0; i < myForceTargets.size(); i++) {
        ForceTarget target = myForceTargets.get(i);
        // TODO: non-enabled connectors should not add to Jacobian -- need to fix
        target.addForceJacobian(myForJacobian, i, targetToConnectorMap[i]);
    }
    if (debug) {
        System.out.println("Jc = " + myForJacobian);
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) SparseBlockMatrix(maspack.matrix.SparseBlockMatrix) VectorNd(maspack.matrix.VectorNd) BodyConnector(artisynth.core.mechmodels.BodyConnector)

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