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);
}
}
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");
}
}
}
}
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()));
}
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");
}
}
}
}
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);
}
}
}
Aggregations