use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class LinearAuxiliaryTest method createCylinder.
FemModel3d createCylinder(double h, double r) {
FemModel3d fem = FemFactory.createCylinder(null, h, r, 24, 40, 4);
fem.setDensity(1000);
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);
}
}
return fem;
}
use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class LinearAuxiliaryTest method createHexGrid.
static FemModel3d createHexGrid(double wx, double wy, double wz, int nx, int ny, int nz) {
FemModel3d fem = FemFactory.createHexGrid(null, wx, wy, wz, nx, ny, nz);
fem.setDensity(1000);
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().x < -wx / 2 + eps) {
node.setDynamic(false);
}
}
return fem;
}
use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class SimpleCollide method setBottomObject.
private void setBottomObject(Collidable comp, ObjectType type) {
Renderable rcomp = (Renderable) comp;
((TransformableGeometry) comp).transformGeometry(AffineTransform3d.createScaling(myBottomScale));
switch(type) {
case FemEllipsoid:
case FemSphere:
{
RenderProps.setPointColor(rcomp, Color.green);
// fix the lower nodes
Point3d min = new Point3d();
RenderableUtils.getBounds(rcomp, min, null);
FemModel3d fem = (FemModel3d) comp;
fem.getSurfaceMesh();
for (FemNode3d n : fem.getNodes()) {
if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.5)) {
n.setDynamic(false);
}
}
fem.resetRestPosition();
break;
}
case FemCube:
{
RenderProps.setPointColor(rcomp, Color.green);
// fix the lower nodes
Point3d min = new Point3d();
RenderableUtils.getBounds(rcomp, min, null);
FemModel3d fem = (FemModel3d) comp;
fem.getSurfaceMesh();
for (FemNode3d n : fem.getNodes()) {
if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.1)) {
n.setDynamic(false);
}
}
// RenderProps.setAlpha (rcomp, 0.3);
fem.resetRestPosition();
break;
}
case Box:
{
((RigidBody) comp).setDynamic(false);
((RigidBody) comp).setDistanceGridRes(new Vector3i(10, 5, 5));
break;
}
case Molar:
{
((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, -1, 0, Math.toRadians(172.09)));
((RigidBody) comp).setDynamic(false);
break;
}
case Bin:
{
((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, 0, 0, 0));
((RigidBody) comp).setDynamic(false);
break;
}
case Paw:
case House:
{
((RigidBody) comp).setDynamic(false);
break;
}
default:
{
throw new InternalErrorException("Unimplemented type " + type);
}
}
myBottomObject = comp;
myBottomType = type;
}
use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class FemBeamWithBlock method build.
public void build(String[] args) throws IOException {
// Build simple FemBeam
super.build(args);
// Create a rigid block and move to the side of FEM
RigidBody block = RigidBody.createBox("block", width / 2, 1.2 * width, 1.2 * width, 2 * density);
mech.addRigidBody(block);
block.setPose(new RigidTransform3d(length / 2 + width / 4, 0, 0));
// Attach right-side nodes to rigid block
for (FemNode3d node : fem.getNodes()) {
if (node.getPosition().x >= length / 2 - EPS) {
mech.addAttachment(new PointFrameAttachment(block, node));
}
}
}
use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class FemBeamTest method build.
@Override
public void build(String[] args) throws IOException {
super.build(args);
mech = new MechModel("mech");
addModel(mech);
fems = new RenderableComponentList<>(FemModel3d.class);
FemModel3d tet = FemFactory.createTetGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
tet.setName("tet");
fems.add(tet);
FemModel3d pyr = FemFactory.createPyramidGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
pyr.setName("pyr");
fems.add(pyr);
FemModel3d wed = FemFactory.createWedgeGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
wed.setName("wed");
fems.add(wed);
FemModel3d hex = FemFactory.createHexGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
hex.setName("hex");
fems.add(hex);
FemModel3d qtet = FemFactory.createQuadtetGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
qtet.setName("qtet");
fems.add(qtet);
FemModel3d qpyr = FemFactory.createQuadpyramidGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
qpyr.setName("qpyr");
fems.add(qpyr);
FemModel3d qwed = FemFactory.createQuadwedgeGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
qwed.setName("qwed");
fems.add(qwed);
FemModel3d qhex = FemFactory.createQuadhexGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
qhex.setName("qhex");
fems.add(qhex);
// freeze lhs nodes
double eps = 1e-10;
for (FemModel3d fem : fems) {
for (FemNode3d node : fem.getNodes()) {
if (node.getRestPosition().x < -widthX / 2 + eps) {
node.setDynamic(false);
}
}
}
// distribute
double delta = widthY * 0.25;
RigidTransform3d translate = new RigidTransform3d();
for (FemModel3d fem : fems) {
fem.transformGeometry(translate);
translate.p.y += widthY + delta;
}
mech.add(fems);
// render properties
int nfems = fems.size();
int ifem = 0;
for (FemModel3d fem : fems) {
fem.setSurfaceRendering(SurfaceRender.Shaded);
float h = (float) ifem / nfems;
RenderProps.setFaceColor(fem, Color.getHSBColor(h, 1.0f, 1.0f));
++ifem;
}
setMaterial(createDefaultMaterial());
}
Aggregations