MeshLib Documentation
Loading...
Searching...
No Matches
Mesh export

Export example of points and triangles from mesh (e.g. for rendering)

  • C++
    #include <MRMesh/MRCube.h>
    #include <MRMesh/MRMesh.h>
    int main()
    {
    // create some mesh
    // all vertices of valid triangles
    const std::vector<std::array<MR::VertId, 3>> triangles = mesh.topology.getAllTriVerts();
    // all point coordinates
    const std::vector<MR::Vector3f> & points = mesh.points.vec_;
    // triangle vertices as tripples of ints (pointing to elements in points vector)
    const int * vertexTripples = reinterpret_cast<const int*>( triangles.data() );
    return 0;
    }
    MRMESH_API std::vector< ThreeVertIds > getAllTriVerts() const
    returns three vertex ids for valid triangles, invalid triangles are skipped
    MRMESH_API Mesh makeCube(const Vector3f &size=Vector3f::diagonal(1.0f), const Vector3f &base=Vector3f::diagonal(-0.5f))
    Definition MRMesh/MRMesh.h:23
    MeshTopology topology
    Definition MRMesh/MRMesh.h:24
    VertCoords points
    Definition MRMesh/MRMesh.h:25
  • Python See a more relevant example Numpy support