libfs
Header-only C++11 library for accessing FreeSurfer neuroimaging data
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
fs::Mesh Struct Reference

Models a triangular mesh, used for brain surface meshes. More...

#include <libfs.h>

Collaboration diagram for fs::Mesh:
Collaboration graph
[legend]

Classes

struct  _tupleHashFunction
 Hash function for 2-tuples of <size_t, sizt_t>, used to hash an edge of a graph or mesh.
 

Public Types

typedef std::unordered_set< std::tuple< size_t, size_t >, _tupleHashFunction > edge_set
 Datastructure for storing, and quickly querying the existence of, mesh edges. More...
 

Public Member Functions

 Mesh (std::vector< float > cvertices, std::vector< int32_t > cfaces)
 Construct a Mesh from the given vertices and faces.
 
 Mesh (std::vector< std::vector< float >> cvertices, std::vector< std::vector< int32_t >> cfaces)
 
 Mesh ()
 Construct an empty Mesh.
 
std::string to_obj () const
 Return string representing the mesh in Wavefront Object (.obj) format. More...
 
std::vector< std::vector< bool > > as_adjmatrix () const
 Return adjacency matrix representation of this mesh. More...
 
edge_set as_edgelist () const
 Return edge list representation of this mesh. More...
 
std::vector< std::vector< size_t > > as_adjlist (const bool via_matrix=true) const
 Return adjacency list representation of this mesh. More...
 
std::vector< float > smooth_pvd_nn (const std::vector< float > pvd, const size_t num_iter=1, const bool via_matrix=true, const bool with_nan=true, const bool detect_nan=true) const
 Smooth given per-vertex data using nearest neighbor smoothing. More...
 
void to_obj_file (const std::string &filename) const
 Export this mesh to a file in Wavefront OBJ format. More...
 
std::pair< std::unordered_map< int32_t, int32_t >, fs::Meshsubmesh_vertex (const std::vector< int32_t > &old_vertex_indices, const bool mapdir_fulltosubmesh=false) const
 Compute a new mesh that is a submesh of this mesh, based on a subset of the vertices of this mesh. More...
 
size_t num_vertices () const
 Return the number of vertices in this mesh. More...
 
size_t num_faces () const
 Return the number of faces in this mesh. More...
 
const int32_t & fm_at (const size_t i, const size_t j) const
 Retrieve a vertex index of a face, treating the faces vector as an nx3 matrix. More...
 
std::vector< int32_t > face_vertices (const size_t face) const
 Get all vertex indices of the face, given by its index. More...
 
std::vector< float > vertex_coords (const size_t vertex) const
 Get all coordinates of the vertex, given by its index. More...
 
const float & vm_at (const size_t i, const size_t j) const
 Retrieve a single (x, y, or z) coordinate of a vertex, treating the vertices vector as an nx3 matrix. More...
 
std::string to_ply () const
 Return string representing the mesh in PLY format. Overload that works without passing a color vector. More...
 
std::string to_ply (const std::vector< uint8_t > col) const
 Return string representing the mesh in PLY format. More...
 
void to_ply_file (const std::string &filename) const
 Export this mesh to a file in Stanford PLY format. More...
 
void to_ply_file (const std::string &filename, const std::vector< uint8_t > col) const
 Export this mesh to a file in Stanford PLY format with vertex colors. More...
 
std::string to_off () const
 Return string representing the mesh in OFF format. Overload that works without passing a color vector. More...
 
std::string to_off (const std::vector< uint8_t > col) const
 Return string representing the mesh in PLY format. More...
 
void to_off_file (const std::string &filename) const
 Export this mesh to a file in OFF format. More...
 
void to_off_file (const std::string &filename, const std::vector< uint8_t > col) const
 Export this mesh to a file in OFF format with vertex colors (COFF). More...
 

Static Public Member Functions

static fs::Mesh construct_cube ()
 Construct and return a simple cube mesh. More...
 
static fs::Mesh construct_pyramid ()
 Construct and return a simple pyramidal mesh. More...
 
static fs::Mesh construct_grid (const size_t nx=4, const size_t ny=5, const float distx=1.0, const float disty=1.0)
 Construct and return a simple planar grid mesh. More...
 
static std::vector< float > smooth_pvd_nn (const std::vector< std::vector< size_t >> mesh_adj, const std::vector< float > pvd, const size_t num_iter=1, const bool with_nan=true, const bool detect_nan=true)
 Smooth given per-vertex data using nearest neighbor smoothing based on adjacency list mesh represenation. More...
 
static std::vector< std::vector< size_t > > extend_adj (const std::vector< std::vector< size_t >> mesh_adj, const size_t extend_by=1, std::vector< std::vector< size_t >> mesh_adj_ext=std::vector< std::vector< size_t >>())
 Extend mesh neighborhoods based on mesh adjacency representation. More...
 
static std::vector< float > curv_data_for_orig_mesh (const std::vector< float > data_submesh, const std::unordered_map< int32_t, int32_t > submesh_to_orig_mapping, const int32_t orig_mesh_num_vertices, const float fill_value=std::numeric_limits< float >::quiet_NaN())
 Given per-vertex data for a submesh, add NAN values inbetween to restore the original mesh size. More...
 
static void from_obj (Mesh *mesh, std::istream *is)
 Read a brainmesh from a Wavefront object format stream. More...
 
static void from_obj (Mesh *mesh, const std::string &filename)
 Read a brainmesh from a Wavefront object format mesh file. More...
 
static void from_off (Mesh *mesh, std::istream *is, const std::string &source_filename="")
 Read a brainmesh from an Object File format (OFF) stream. More...
 
static void from_off (Mesh *mesh, const std::string &filename)
 Read a brainmesh from an OFF format mesh file. More...
 
static void from_ply (Mesh *mesh, std::istream *is)
 Read a brainmesh from a Stanford PLY format stream. More...
 
static void from_ply (Mesh *mesh, const std::string &filename)
 Read a brainmesh from a Stanford PLY format mesh file. More...
 

Public Attributes

std::vector< float > vertices
 n x 3 vector of the x,y,z coordinates for the n vertices. The x,y,z coordinates for a single vertex form consecutive entries.
 
std::vector< int32_t > faces
 n x 3 vector of the 3 vertex indices for the n triangles or faces. The 3 vertices of a single face form consecutive entries.
 

Detailed Description

Models a triangular mesh, used for brain surface meshes.

Represents a vertex-indexed mesh. The n vertices are stored as 3D point coordinates (x,y,z) in a vector of length 3n, in which 3 consecutive values represent the x, y and z coordinate of the same vertex. The m faces are stored as a vector of 3m integers, where 3 consecutive values represent the 3 vertices (by index) making up the respective face. Vertex indices are 0-based.

Examples

size_t nv = surface.num_vertices(); // 8
auto first_face_verts = surface.face_vertices(0);
int first_face_third_vert = surface.fm_at(0, 2);
size_t nf = surface.num_faces();
size_t nv = surface.num_vertices();
surface.to_obj("cube_out.obj");

Member Typedef Documentation

◆ edge_set

typedef std::unordered_set<std::tuple<size_t, size_t>, _tupleHashFunction> fs::Mesh::edge_set

Datastructure for storing, and quickly querying the existence of, mesh edges.

This is an unordered set of 2-tuples, where each tuple represents an edge, given as a pair of vertex indices. Each edge occurs twice in the list, once as make_tuple(i,j) and once as make_tuple(j,i). Use the API of std::unordered_set to interact with it.

Member Function Documentation

◆ as_adjlist()

std::vector<std::vector<size_t> > fs::Mesh::as_adjlist ( const bool  via_matrix = true) const
inline

Return adjacency list representation of this mesh.

Parameters
via_matrixwhether the computation should be done via an step involving an adjacency matrix, or via an edge set. Leaving this at true temporarily requires a lot of memory for large meshes, but is faster.
Returns
vector of vectors, where the outer vector has size this->num_vertices. The inner vector at index N contains the M neighbors of vertex n, as vertex indices.
See also
fs::Mesh::to_rep_adjmatrix gives you an adjacency matrix instead.

Examples

std::vector<std::vector<size_t>> adjl = surface.as_adjlist();
std::vector<std::vector<size_t>> adjl1 = surface.as_adjlist(true);

◆ as_adjmatrix()

std::vector<std::vector<bool> > fs::Mesh::as_adjmatrix ( ) const
inline

Return adjacency matrix representation of this mesh.

Returns
boolean 2D matrix, where true means an edge between the respective vertex pair exists, and false mean it does not.
See also
fs::Mesh::to_rep_adjlist gives you an adjacency list instead.
Note
This requires a lot of memory for large meshes.

Examples

std::vector<std::vector<bool>> adjm = surface.as_adjmatrix();

◆ as_edgelist()

edge_set fs::Mesh::as_edgelist ( ) const
inline

Return edge list representation of this mesh.

Note
While this mesh or graph representation is typically known as an edge list, this function actually returns a set.
Returns
an fs::Mesh::edge_set, i.e., an unordered set of 2-tuples, where each tuple represents an edge, given as a pair of vertex indices. Each edge occurs twice in the list, once as make_tuple(i,j) and once as make_tuple(j,i).

Examples

edge_set edges = surface.as_edgelist();
size_t num_undirected_edges = edg es.size() / 2;

◆ construct_cube()

static fs::Mesh fs::Mesh::construct_cube ( )
inlinestatic

Construct and return a simple cube mesh.

Returns
fs::Mesh instance representing a cube.

Examples

size_t nv = surface.num_vertices(); // 8
size_t nf = surface.num_faces(); // 12

◆ construct_grid()

static fs::Mesh fs::Mesh::construct_grid ( const size_t  nx = 4,
const size_t  ny = 5,
const float  distx = 1.0,
const float  disty = 1.0 
)
inlinestatic

Construct and return a simple planar grid mesh.

This is a 2D rectangular grid embedded in 3D. Each rectangular cell consists of 2 triangular faces. The height (z coordinate) for all vertices is 0.0.

Parameters
nxnumber of vertices in x direction
nynumber of vertices in y direction
distxdistance between vertices in x direction
distydistance between vertices in y direction
Returns
fs::Mesh instance representing a flat grid.
Exceptions
std::invalid_argumenterror if nx or ny are < 2.

Examples

size_t nv = surface.num_vertices(); // 4*5 = 20
size_t nf = surface.num_faces(); // (4-1)*(5-1)*2 = 24;

◆ construct_pyramid()

static fs::Mesh fs::Mesh::construct_pyramid ( )
inlinestatic

Construct and return a simple pyramidal mesh.

This constructs a right square pyramid with base edge length 1 and height 1. Think of the Great Pyramid of Giza.

Returns
fs::Mesh instance representing a 4-sided pyramid.

Examples

size_t nv = surface.num_vertices(); // 5
size_t nf = surface.num_faces(); // 6

◆ curv_data_for_orig_mesh()

static std::vector<float> fs::Mesh::curv_data_for_orig_mesh ( const std::vector< float >  data_submesh,
const std::unordered_map< int32_t, int32_t >  submesh_to_orig_mapping,
const int32_t  orig_mesh_num_vertices,
const float  fill_value = std::numeric_limits<float>::quiet_NaN() 
)
inlinestatic

Given per-vertex data for a submesh, add NAN values inbetween to restore the original mesh size.

Parameters
data_submeshvector of per-vertex data values, one value per mesh vertex of the submesh.
submesh_to_orig_mappingmap<int, int>, mapping vertex indices of the submesh to vertex indices of the original, full mesh.
orig_mesh_num_verticesnumber of vertices of the original, full mesh.
See also
fs::Mesh::submesh_vertex for how to get the submesh_to_orig_mapping parameter.
Returns
vector of per-vertex data values, one value per mesh vertex of the original mesh. Values for vertices that are not part of the submesh are set to NAN.

◆ extend_adj()

static std::vector<std::vector<size_t> > fs::Mesh::extend_adj ( const std::vector< std::vector< size_t >>  mesh_adj,
const size_t  extend_by = 1,
std::vector< std::vector< size_t >>  mesh_adj_ext = std::vector<std::vector<size_t>>() 
)
inlinestatic

Extend mesh neighborhoods based on mesh adjacency representation.

This function is mainly extended to extend a source neighborhood representation (typically the mesh's k=1 neighborhood, i.e., the adjacency list of the mesh) to a higher k. In a k=3 neighborhood, the neighorhood around a source vertex includes all vertices in edge distance up to 3 from the source vertex (but not the source vertex itself).

Parameters
mesh_adjThe adjacency list representation of the underlying mesh, the outer vector must have size N for a mesh with N vertices.
extend_bythe number of edges to hop to extend the neighborhoods.
mesh_adj_extthe starting neighborhoods to extend, same representation as mesh_adj. The outer vector must have size N or 0. If passed as an empty vector, this will be ignored and a copy of the mesh_adj is used as the start_neighborhoods.
Returns
extended neighborhoods

◆ face_vertices()

std::vector<int32_t> fs::Mesh::face_vertices ( const size_t  face) const
inline

Get all vertex indices of the face, given by its index.

Parameters
facethe face index
Returns
vector of length 3, the vertex indices of the face.
Exceptions
std::range_erroron invalid index

Examples

auto first_face_verts = surface.face_vertices(0);

◆ fm_at()

const int32_t& fs::Mesh::fm_at ( const size_t  i,
const size_t  j 
) const
inline

Retrieve a vertex index of a face, treating the faces vector as an nx3 matrix.

Parameters
ithe row index, valid values are 0..num_faces-1.
jthe column index, valid values are 0..2 (for the 3 vertices of a face).
Exceptions
std::range_erroron invalid index
Returns
vertex index of vertex j of face i

Examples

int first_face_third_vert = surface.fm_at(0, 2);

◆ from_obj() [1/2]

static void fs::Mesh::from_obj ( Mesh mesh,
std::istream *  is 
)
inlinestatic

Read a brainmesh from a Wavefront object format stream.

This only reads the geometry, optional format extensions like materials are ignored (but files including them should parse fine).

Parameters
meshpointer to fs:Mesh instance to be filled.
isstream holding a text representation of a mesh in Wavefront object format.
See also
There exists an overloaded version that reads from a file.
Exceptions
std::domain_errorif the file format is invalid.

Examples

fs::Mesh surface;
const std::string in_path = fs::util::fullpath({"/tmp", "mesh.obj"});
fs::Mesh::from_obj(&surface, in_path);

◆ from_obj() [2/2]

static void fs::Mesh::from_obj ( Mesh mesh,
const std::string &  filename 
)
inlinestatic

Read a brainmesh from a Wavefront object format mesh file.

This only reads the geometry, optional format extensions like materials are ignored (but files including them should parse fine).

See also
There exists an overloaded version that reads from a stream.
Parameters
meshpointer to fs:Mesh instance to be filled.
filenamepath to input wavefront obj mesh to be read.
Exceptions
std::runtime_errorif the file cannot be read.
std::domain_errorif the file format is invalid.

Examples

fs::Mesh surface;
fs::Mesh::from_obj(&surface, "mesh.obj");

◆ from_off() [1/2]

static void fs::Mesh::from_off ( Mesh mesh,
std::istream *  is,
const std::string &  source_filename = "" 
)
inlinestatic

Read a brainmesh from an Object File format (OFF) stream.

Parameters
meshpointer to fs:Mesh instance to be filled.
isAn open std::istream or derived class stream from which to read the data, e.g., std::ifstream or std::istringstream.
source_filenameoptional, used in error messages only. The source file name, if any.
See also
There exists an overloaded version that reads from a file.
Exceptions
std::domain_errorif the file format is invalid.

◆ from_off() [2/2]

static void fs::Mesh::from_off ( Mesh mesh,
const std::string &  filename 
)
inlinestatic

Read a brainmesh from an OFF format mesh file.

See also
There exists an overloaded version that reads from a stream.

The OFF is the Object File Format (file extension .off) is a simple text-based mesh file format. Not to be confused with the Wavefront Object format (.obj).

Parameters
meshpointer to fs:Mesh instance to be filled.
filenamepath to input wavefront obj mesh to be read.
Exceptions
std::runtime_errorif the file cannot be read.
std::domain_errorif the file format is invalid.

Examples

fs::Mesh surface;
fs::Mesh::from_off(&surface, "mesh.off");

◆ from_ply() [1/2]

static void fs::Mesh::from_ply ( Mesh mesh,
std::istream *  is 
)
inlinestatic

Read a brainmesh from a Stanford PLY format stream.

Parameters
meshpointer to fs:Mesh instance to be filled.
isAn open std::istream or derived class stream from which to read the data, e.g., std::ifstream or std::istringstream.
See also
There exists an overloaded version that reads from a file.
Exceptions
std::domain_errorif the file format is invalid.

◆ from_ply() [2/2]

static void fs::Mesh::from_ply ( Mesh mesh,
const std::string &  filename 
)
inlinestatic

Read a brainmesh from a Stanford PLY format mesh file.

The PLY format exists in text and binary forms, and the binary form can be little endian or big endian. This file reads the ASCII text format version.

Parameters
meshpointer to fs:Mesh instance to be filled.
filenamepath to input wavefront obj mesh to be read.
Exceptions
std::runtime_errorif the file cannot be read.
std::domain_errorif the file format is invalid.

Examples

fs::Mesh surface;
fs::Mesh::from_ply(&surface, "mesh.ply");

◆ num_faces()

size_t fs::Mesh::num_faces ( ) const
inline

Return the number of faces in this mesh.

Returns
the face count

Examples

size_t nv = surface.num_faces();

◆ num_vertices()

size_t fs::Mesh::num_vertices ( ) const
inline

Return the number of vertices in this mesh.

Returns
the vertex count

Examples

size_t nv = surface.num_vertices();

◆ smooth_pvd_nn() [1/2]

std::vector<float> fs::Mesh::smooth_pvd_nn ( const std::vector< float >  pvd,
const size_t  num_iter = 1,
const bool  via_matrix = true,
const bool  with_nan = true,
const bool  detect_nan = true 
) const
inline

Smooth given per-vertex data using nearest neighbor smoothing.

Parameters
pvdvector of per-vertex data values, one value per mesh vertex.
num_iternumber of iterations of smoothing to perform.
via_matrixpassed on to this->as_asjlist(), whether to construct the adjacency list of the mesh using an intermediate step involving an adjacency matrix, as opposed to using an edge set. The latter is slower but requires less memory.
with_nanwhether you need support for NAN values in pvd. A bit slower if active. Ignored if detectnan is true.
detect_nanwhether to auto-detect presence of NAN values, ignoring the setting of with_nan.
Returns
vector of smoothed per-vertex data values, same length as pvd param.

Examples

std::vector<float> pvd = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7};
std::vector<float> pvd_smooth = surface.smooth_pvd_nn(pvd, 2);

◆ smooth_pvd_nn() [2/2]

static std::vector<float> fs::Mesh::smooth_pvd_nn ( const std::vector< std::vector< size_t >>  mesh_adj,
const std::vector< float >  pvd,
const size_t  num_iter = 1,
const bool  with_nan = true,
const bool  detect_nan = true 
)
inlinestatic

Smooth given per-vertex data using nearest neighbor smoothing based on adjacency list mesh represenation.

Parameters
mesh_adjthe mesh, given as an adjacency list. The outer vector has size num_vertices, and the inner vectors sizes are the number of neighbors of the respective vertex.
pvdvector of per-vertex data values, one value per mesh vertex. Must not include NAN values. See smooth_pvd_nn_nan if you need support for NAN values.
num_iternumber of iterations of smoothing to perform.
with_nanwhether you need support for NAN values in pvd. A bit slower if active. Ignored if detectnan is true.
detect_nanwhether to auto-detect presence of NAN values, ignoring the setting of with_nan.
Returns
vector of smoothed per-vertex data values, same length as pvd param.

Examples

std::vector<std::vector<size_t>> mesh_adj = surface.as_adjlist();
std::vector<float> pvd = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7};
std::vector<float> pvd_smooth = fs::Mesh::smooth_pvd_nn(mesh_adj, pvd, 2);

◆ submesh_vertex()

std::pair<std::unordered_map<int32_t, int32_t>, fs::Mesh> fs::Mesh::submesh_vertex ( const std::vector< int32_t > &  old_vertex_indices,
const bool  mapdir_fulltosubmesh = false 
) const
inline

Compute a new mesh that is a submesh of this mesh, based on a subset of the vertices of this mesh.

Parameters
old_vertex_indicesvector of vertex indices of this mesh, which should be included in the submesh.
mapdir_fulltosubmeshwhether to return a map from the old (full mesh) to the new (submesh) vertex indices (true), or the other way around (false, the default) as the first element of the returned pair.
Returns
a pair of the vertex index map (direction 'fullmesh to submesh' by default, but see 'mapdir_fulltosubmesh' parameter) and the submesh.

Examples

fs::Mesh surface;
fs::read_surf(&surface, "examples/read_surf/lh.white");
fs::Label label;
fs::read_label(&label, "examples/read_label/lh.cortex.label");
std::pair <std::unordered_map<int32_t, int32_t>, fs::Mesh> result = surface.submesh_vertex(label.vertex);
fs::Mesh patch = result.second;
auto vertexindexmap_submesh2full = result.first; // or '<std::unordered_map<int32_t, int32_t>' instead of 'auto'.

◆ to_obj()

std::string fs::Mesh::to_obj ( ) const
inline

Return string representing the mesh in Wavefront Object (.obj) format.

Returns
Wavefront Object string representation of the mesh, including vertices and faces.
See also
fs::Mesh::to_obj_file is a shortcut if you want to export the string representation to a file.

Examples

std::str mesh_repr_off = surface.to_obj();

◆ to_obj_file()

void fs::Mesh::to_obj_file ( const std::string &  filename) const
inline

Export this mesh to a file in Wavefront OBJ format.

Parameters
filenamepath to the output file, will be overwritten if existing.
Exceptions
std::runtime_errorif the target file cannot be opened.
See also
fs::Mesh::to_obj if you want the string representation (without writing it to a file).

Examples

const std::string out_path = fs::util::fullpath({"/tmp", "mesh.obj"});
surface.to_obj_file(out_path);

◆ to_off() [1/2]

std::string fs::Mesh::to_off ( ) const
inline

Return string representing the mesh in OFF format. Overload that works without passing a color vector.

Examples

std::string off_rep = surface.to_off();

◆ to_off() [2/2]

std::string fs::Mesh::to_off ( const std::vector< uint8_t >  col) const
inline

Return string representing the mesh in PLY format.

Parameters
colu_char vector of RGB color values, 3 per vertex. They must appear by vertex, i.e. in order v0_red, v0_green, v0_blue, v1_red, v1_green, v1_blue. Leave empty if you do not want colors.
Exceptions
std::invalid_argumentif the number of vertex colors does not match the number of vertices.

◆ to_off_file() [1/2]

void fs::Mesh::to_off_file ( const std::string &  filename) const
inline

Export this mesh to a file in OFF format.

Exceptions
std::runtime_errorif the target file cannot be opened.

Examples

surface.to_off_file("mesh.off");

◆ to_off_file() [2/2]

void fs::Mesh::to_off_file ( const std::string &  filename,
const std::vector< uint8_t >  col 
) const
inline

Export this mesh to a file in OFF format with vertex colors (COFF).

Exceptions
std::runtime_errorif the target file cannot be opened, std::invalid_argument if the number of vertex colors does not match the number of vertices.

◆ to_ply() [1/2]

std::string fs::Mesh::to_ply ( ) const
inline

Return string representing the mesh in PLY format. Overload that works without passing a color vector.

Examples

std::string ply_rep = surface.to_ply();

◆ to_ply() [2/2]

std::string fs::Mesh::to_ply ( const std::vector< uint8_t >  col) const
inline

Return string representing the mesh in PLY format.

Parameters
colu_char vector of RGB color values, 3 per vertex. They must appear by vertex, i.e. in order v0_red, v0_green, v0_blue, v1_red, v1_green, v1_blue. Leave empty if you do not want colors.
Exceptions
std::invalid_argumentif the number of vertex colors does not match the number of vertices.

Examples

std::string ply_rep = surface.to_ply();

◆ to_ply_file() [1/2]

void fs::Mesh::to_ply_file ( const std::string &  filename) const
inline

Export this mesh to a file in Stanford PLY format.

Exceptions
std::runtime_errorif the target file cannot be opened.

Examples

surface.to_ply_file("mesh.ply");

◆ to_ply_file() [2/2]

void fs::Mesh::to_ply_file ( const std::string &  filename,
const std::vector< uint8_t >  col 
) const
inline

Export this mesh to a file in Stanford PLY format with vertex colors.

Exceptions
std::runtime_errorif the target file cannot be opened, std::invalid_argument if the number of vertex colors does not match the number of vertices.

◆ vertex_coords()

std::vector<float> fs::Mesh::vertex_coords ( const size_t  vertex) const
inline

Get all coordinates of the vertex, given by its index.

Parameters
vertexthe vertex index
Returns
vector of length 3, the x,y,z coordinates of the vertex.
Exceptions
std::range_erroron invalid index

Examples

auto coords = surface.vertex_coords(0);

◆ vm_at()

const float& fs::Mesh::vm_at ( const size_t  i,
const size_t  j 
) const
inline

Retrieve a single (x, y, or z) coordinate of a vertex, treating the vertices vector as an nx3 matrix.

Parameters
ithe row index, valid values are 0..num_vertices.
jthe column index, valid values are 0..2 (for the x,y,z coordinates).
Exceptions
std::range_erroron invalid index

Examples

float v5_x = surface.vm_at(5, 0);
float v5_y = surface.vm_at(5, 1);
float v5_z = surface.vm_at(5, 2);

The documentation for this struct was generated from the following file: