use of maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class FemMeshBase method setMeshFromInfo.
public void setMeshFromInfo() {
// Overridden from super class. Is called by super.setMesh() and by scan
// (whenever a mesh is scanned) to set mesh properties and auxiliary
// data structures specific to the class.
MeshBase mesh = getMesh();
if (mesh != null) {
mesh.setFixed(false);
mesh.setColorsFixed(false);
mesh.setColorInterpolation(getColorInterpolation());
}
}
use of maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class FemMeshBase method doSetMesh.
protected void doSetMesh(MeshBase mesh, String fileName, AffineTransform3dBase X) {
MeshBase oldMesh = getMesh();
if (oldMesh != null && isStressOrStrainRendering(mySurfaceRendering)) {
restoreMeshColoring(oldMesh);
}
super.doSetMesh(mesh, fileName, X);
if (isStressOrStrainRendering(mySurfaceRendering)) {
saveMeshColoring(mesh);
mesh.setVertexColoringEnabled();
// not sure we need this here
updateVertexColors();
}
}
use of maspack.geometry.MeshBase 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 maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class MeshComponent method setMeshFromInfo.
protected void setMeshFromInfo() {
MeshBase mesh = getMesh();
if (mesh != null) {
mesh.setFixed(true);
mesh.setColorInterpolation(getColorInterpolation());
mesh.setVertexColorMixing(getVertexColorMixing());
}
}
use of maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class MFreeMeshComp method updateVertexColors.
protected void updateVertexColors() {
if (mySurfaceRendering != SurfaceRender.Stress && mySurfaceRendering != SurfaceRender.Strain) {
return;
}
if (myStressPlotRanging == Ranging.Auto) {
myStressPlotRange.merge(myModel.getNodalPlotRange(mySurfaceRendering));
}
RenderProps rprops = getRenderProps();
float alpha = (float) rprops.getAlpha();
MeshBase mesh = getMesh();
double sval = 0;
for (int i = 0; i < myVertexAttachments.size(); i++) {
PointAttachment attacher = myVertexAttachments.get(i);
sval = 0;
if (attacher instanceof PointFem3dAttachment) {
PointFem3dAttachment pfa = (PointFem3dAttachment) attacher;
FemNode[] nodes = pfa.getNodes();
VectorNd weights = pfa.getCoordinates();
for (int j = 0; j < nodes.length; j++) {
if (nodes[j] instanceof MFreeNode3d) {
// paranoid!
MFreeNode3d node = (MFreeNode3d) nodes[j];
double w = weights.get(j);
if (mySurfaceRendering == SurfaceRender.Strain) {
sval += w * node.getVonMisesStrain();
} else if (mySurfaceRendering == SurfaceRender.Stress) {
sval += w * node.getVonMisesStress();
}
}
}
} else if (attacher instanceof PointParticleAttachment) {
PointParticleAttachment ppa = (PointParticleAttachment) attacher;
MFreeNode3d node = (MFreeNode3d) ppa.getParticle();
if (mySurfaceRendering == SurfaceRender.Strain) {
sval = node.getVonMisesStrain();
} else if (mySurfaceRendering == SurfaceRender.Stress) {
sval = node.getVonMisesStress();
}
}
double smin = myStressPlotRange.getLowerBound();
double srng = myStressPlotRange.getRange();
double c = (sval - smin) / srng;
c = Math.max(0, Math.min(c, 1.0));
myColorMap.getRGB(c, colorArray);
mesh.setColor(i, colorArray[0], colorArray[1], colorArray[2], alpha);
}
}
Aggregations