use of maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class FixedMeshBody method scan.
public void scan(ReaderTokenizer rtok, Object ref) throws IOException {
super.scan(rtok, ref);
MeshBase mesh = getMesh();
if (mesh != null) {
mesh.setFixed(true);
mesh.setMeshToWorld(myState.XFrameToWorld);
}
}
use of maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class VertexComponent method transformGeometry.
public void transformGeometry(GeometryTransformer gtr, TransformGeometryContext context, int flags) {
MeshBase m = myVertex.getMesh();
if (m == null || m.getMeshToWorld().isIdentity()) {
gtr.transformPnt(myVertex.pnt);
} else {
// relative transform
myVertex.pnt.transform(m.getMeshToWorld());
gtr.transformPnt(myVertex.pnt);
myVertex.pnt.inverseTransform(m.getMeshToWorld());
}
notifyVertexPositionModified();
}
use of maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class MeshInfo method printInfo.
public void printInfo(File inputFile) throws IOException {
MeshBase mesh = getMesh(inputFile);
if (mesh instanceof PolygonalMesh) {
PolygonalMesh pmesh = (PolygonalMesh) mesh;
System.out.println("meshType= " + mesh.getClass());
System.out.println("numVertices= " + pmesh.numVertices());
System.out.println("numFaces= " + pmesh.numFaces());
System.out.println("isClosed= " + pmesh.isClosed());
System.out.println("isManifold= " + pmesh.isManifold());
System.out.println("volume= " + pmesh.computeVolume());
System.out.println("area= " + pmesh.computeArea());
System.out.println("averageEdgeLength= " + pmesh.computeAverageEdgeLength());
doPrintBounds(pmesh);
} else if (mesh != null) {
System.out.println("meshType= " + mesh.getClass());
System.out.println("numVertices= " + mesh.numVertices());
doPrintBounds(mesh);
}
}
use of maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class MeshThicken method loadMesh.
public void loadMesh(File file, int vertexSkip) {
try {
MeshBase mesh = null;
if (file.getName().endsWith(".xyzb")) {
XyzbReader reader = new XyzbReader(file);
reader.setSkip(vertexSkip);
mesh = reader.readMesh();
} else {
mesh = GenericMeshReader.readMesh(file);
}
removeMesh();
myMesh = mesh;
RenderProps.setFaceStyle(mesh, Renderer.FaceStyle.FRONT_AND_BACK);
RenderProps.setBackColor(mesh, new Color(1f, 204 / 255f, 51 / 355f));
viewer.addRenderable(myMesh);
viewer.repaint();
myMeshFile = file;
System.out.println("num vertices: " + mesh.numVertices());
if (mesh instanceof PolygonalMesh) {
PolygonalMesh pmesh = (PolygonalMesh) mesh;
System.out.println("num faces: " + pmesh.numFaces());
}
setTitle("MeshThicken " + file.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
use of maspack.geometry.MeshBase in project artisynth_core by artisynth.
the class MeshViewer method smoothMeshes.
private void smoothMeshes() {
for (MeshBase m : myMeshes) {
if (m instanceof PolygonalMesh) {
PolygonalMesh pmesh = (PolygonalMesh) m;
LaplacianSmoother.smooth(pmesh, mySmoothingCount, mySmoothingLambda, mySmoothingMu);
pmesh.notifyVertexPositionsModified();
}
}
viewer.rerender();
}
Aggregations