Search in sources :

Example 91 with PolygonalMesh

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();
    }
}
Also used : Color(java.awt.Color) MeshBase(maspack.geometry.MeshBase) PolygonalMesh(maspack.geometry.PolygonalMesh) IOException(java.io.IOException) XyzbReader(maspack.geometry.io.XyzbReader)

Example 92 with PolygonalMesh

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();
}
Also used : MeshBase(maspack.geometry.MeshBase) PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 93 with PolygonalMesh

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);
}
Also used : PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 94 with PolygonalMesh

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);
}
Also used : PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 95 with PolygonalMesh

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 });
}
Also used : Vector3d(maspack.matrix.Vector3d) ArrayList(java.util.ArrayList) PolygonalMesh(maspack.geometry.PolygonalMesh)

Aggregations

PolygonalMesh (maspack.geometry.PolygonalMesh)128 Point3d (maspack.matrix.Point3d)30 Vertex3d (maspack.geometry.Vertex3d)24 Vector3d (maspack.matrix.Vector3d)23 RigidTransform3d (maspack.matrix.RigidTransform3d)21 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)18 File (java.io.File)14 Face (maspack.geometry.Face)14 ContactPoint (artisynth.core.mechmodels.ContactPoint)11 Point (artisynth.core.mechmodels.Point)11 PointParticleAttachment (artisynth.core.mechmodels.PointParticleAttachment)10 Color (java.awt.Color)10 MeshBase (maspack.geometry.MeshBase)10 RigidBody (artisynth.core.mechmodels.RigidBody)9 MechModel (artisynth.core.mechmodels.MechModel)8 BufferedReader (java.io.BufferedReader)8 AxisAngle (maspack.matrix.AxisAngle)8 RenderProps (maspack.render.RenderProps)8 HashMap (java.util.HashMap)7