Search in sources :

Example 26 with MeshBase

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

Example 27 with MeshBase

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

Example 28 with MeshBase

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

Example 29 with MeshBase

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

Example 30 with MeshBase

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

Aggregations

MeshBase (maspack.geometry.MeshBase)39 PolygonalMesh (maspack.geometry.PolygonalMesh)10 ContactPoint (artisynth.core.mechmodels.ContactPoint)5 Point (artisynth.core.mechmodels.Point)5 SkinMeshBase (artisynth.core.mechmodels.SkinMeshBase)5 FemMeshBase (artisynth.core.femmodels.FemMeshBase)3 Point (java.awt.Point)3 SurfaceRender (artisynth.core.femmodels.FemModel.SurfaceRender)2 PointAttachment (artisynth.core.mechmodels.PointAttachment)2 PointParticleAttachment (artisynth.core.mechmodels.PointParticleAttachment)2 Color (java.awt.Color)2 File (java.io.File)2 PointMesh (maspack.geometry.PointMesh)2 Vertex3d (maspack.geometry.Vertex3d)2 XyzbReader (maspack.geometry.io.XyzbReader)2 VectorNd (maspack.matrix.VectorNd)2 RenderProps (maspack.render.RenderProps)2 ArgParser (argparser.ArgParser)1 FemNode (artisynth.core.femmodels.FemNode)1 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)1