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