use of maspack.geometry.PolygonalMesh 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.PolygonalMesh 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();
}
use of maspack.geometry.PolygonalMesh in project artisynth_core by artisynth.
the class MeshViewer method setLabelText.
private void setLabelText(String name, MeshBase mesh) {
System.out.println("numv=" + mesh.numVertices());
String text = name == null ? " " : name;
text += " numv=" + mesh.numVertices();
if (mesh instanceof PolygonalMesh) {
PolygonalMesh pmesh = (PolygonalMesh) mesh;
text += " manifold=" + pmesh.isManifold();
text += " closed=" + pmesh.isClosed();
}
myMeshLabel.setText(text);
}
use of maspack.geometry.PolygonalMesh in project artisynth_core by artisynth.
the class NURBSCurve2dTest method addBox.
public void addBox() {
PolygonalMesh box = MeshFactory.createBox(1, 1, 1);
myFrame.addRenderable(box);
}
use of maspack.geometry.PolygonalMesh in project artisynth_core by artisynth.
the class NagataDistanceTest method createTriangleMesh.
public void createTriangleMesh() {
myBaseMesh = new PolygonalMesh();
myBaseMesh.addVertex(1, 0, 0);
myBaseMesh.addVertex(-0.5, 0.5, 0.5);
myBaseMesh.addVertex(-0.5, -0.5, 0.5);
myBaseMesh.addFace(new int[] { 0, 1, 2 });
ArrayList<Vector3d> normals = new ArrayList<Vector3d>();
Vector3d n0 = new Vector3d(0.5, 0, 1);
Vector3d n1 = new Vector3d(-0.2, 0.4, 1);
Vector3d n2 = new Vector3d(-0.2, -0.4, 1);
n0 = new Vector3d(0.994821588150, 0.0, -0.10163664570324002);
n1 = new Vector3d(-0.39964089136, 0.759875873293, 0.512714165140);
n2 = new Vector3d(-0.39964089136452324, -0.7598758732934454, 0.51271416514066);
normals.add(n0);
normals.add(n1);
normals.add(n2);
myBaseMesh.setNormals(normals, new int[] { 0, 1, 2 });
}
Aggregations