use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.
the class FemMeshComp method setVertexAttachment.
public void setVertexAttachment(int vidx, double[] weights, FemNode3d[] nodes) {
if (weights.length > 1) {
PointFem3dAttachment pattacher = new PointFem3dAttachment();
pattacher.setFromNodes(nodes, weights);
setVertexAttachment(vidx, pattacher);
} else if (weights.length == 1) {
PointParticleAttachment attacher = new PointParticleAttachment(nodes[0], null);
setVertexAttachment(vidx, attacher);
}
}
use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.
the class FemMeshComp method getVertexMasters.
public void getVertexMasters(List<ContactMaster> mlist, Vertex3d vtx) {
PointAttachment pa = getAttachment(vtx.getIndex());
if (pa instanceof PointFem3dAttachment) {
PointFem3dAttachment pfa = (PointFem3dAttachment) pa;
FemNode[] masters = pfa.getNodes();
for (int j = 0; j < masters.length; j++) {
mlist.add(new ContactMaster(masters[j], pfa.getCoordinate(j)));
}
} else {
PointParticleAttachment ppa = (PointParticleAttachment) pa;
mlist.add(new ContactMaster((FemNode3d) ppa.getParticle(), 1));
}
}
use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.
the class FemMeshComp method scanAttachment.
protected void scanAttachment(ReaderTokenizer rtok, Deque<ScanToken> tokens) throws IOException {
ArrayList<Double> weights = new ArrayList<Double>();
rtok.scanToken('[');
tokens.offer(ScanToken.BEGIN);
while (ScanWriteUtils.scanAndStoreReference(rtok, tokens)) {
weights.add(rtok.scanNumber());
}
if (rtok.ttype != ']') {
throw new IOException("Expected ']', got " + rtok);
}
// while (rtok.nextToken() != ']') {
// rtok.pushBack();
// ScanWriteUtils.scanReferenceToken (rtok, tokens);
// weights.add (rtok.scanNumber());
// }
// add null terminator
tokens.offer(ScanToken.END);
if (weights.size() == 1) {
PointParticleAttachment ppa = new PointParticleAttachment();
myVertexAttachments.add(ppa);
} else {
PointFem3dAttachment pfa = new PointFem3dAttachment();
tokens.offer(new ObjectToken(ArraySupport.toDoubleArray(weights)));
myVertexAttachments.add(pfa);
}
}
use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.
the class FemMeshComp method updateVertexColors.
protected void updateVertexColors() {
if (mySurfaceRendering != SurfaceRender.Stress && mySurfaceRendering != SurfaceRender.Strain) {
return;
}
if (myStressPlotRanging == Ranging.Auto) {
myStressPlotRange.merge(myFem.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 FemNode3d) {
// paranoid!
FemNode3d node = (FemNode3d) 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;
FemNode3d node = (FemNode3d) 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);
}
}
use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.
the class MFreeMeshComp method getVertexMasters.
public void getVertexMasters(List<ContactMaster> mlist, Vertex3d vtx) {
PointAttachment pa = getAttachment(vtx.getIndex());
if (pa instanceof PointFem3dAttachment) {
PointFem3dAttachment pfa = (PointFem3dAttachment) pa;
FemNode[] masters = pfa.getNodes();
for (int j = 0; j < masters.length; j++) {
mlist.add(new ContactMaster(masters[j], pfa.getCoordinate(j)));
}
} else {
PointParticleAttachment ppa = (PointParticleAttachment) pa;
mlist.add(new ContactMaster((MFreeNode3d) ppa.getParticle(), 1));
}
}
Aggregations