Principal Component Analysis on a set of mesh vertices. More...
#include <imesh_pca.h>
Public Types | |
enum | tex_coord_type { TEX_COORD_NONE = 0, TEX_COORD_ON_VERT = 1, TEX_COORD_ON_CORNER = 2 } |
This type indicates how texture coordinates are indexed. More... | |
Public Member Functions | |
imesh_pca_mesh () | |
Default Constructor. | |
imesh_pca_mesh (const vcl_vector< imesh_mesh > &meshes) | |
Constructor from a vector of meshes with the same topology. | |
imesh_pca_mesh (const imesh_mesh &mesh, const vnl_vector< double > &mean, const vnl_vector< double > &std_devs, const vnl_matrix< double > &pc) | |
Constructor from a mesh, mean, standard deviations, and PC matrix. | |
imesh_pca_mesh (const imesh_pca_mesh &other) | |
Copy Constructor. | |
imesh_pca_mesh & | operator= (const imesh_pca_mesh &other) |
Assignment operator. | |
void | init (const vnl_vector< double > &mean, const vnl_vector< double > &std_devs, const vnl_matrix< double > &pc) |
Initialize the PCA data (assuming mesh data is already set). | |
void | set_params (const vnl_vector< double > &p) |
Set the pca parameters. | |
void | set_param (unsigned int i, double param) |
Set an individual pca parameter. | |
const vnl_vector< double > & | params () const |
Access the params. | |
const vnl_matrix< double > & | principal_comps () const |
Access the principal components. | |
const vnl_vector< double > & | std_devs () const |
Access the standard deviations. | |
void | set_mean () |
Reset all the PCA parameters to zero. | |
vnl_vector< double > | project (const imesh_vertex_array_base &verts) const |
Project mesh vertices into the PCA parameter space. | |
const imesh_vertex_array_base & | mean_vertices () const |
Access the vector of mean vertices. | |
imesh_vertex_array_base & | mean_vertices () |
template<unsigned int d> | |
const imesh_vertex_array< d > & | mean_vertices () const |
Access the vector of mean vertices cast to a dimension. | |
template<unsigned int d> | |
imesh_vertex_array< d > & | mean_vertices () |
unsigned int | num_verts () const |
Return the number of vertices. | |
unsigned int | num_faces () const |
Return the number of faces. | |
unsigned int | num_edges () const |
Return the number of edges. | |
void | merge (const imesh_mesh &other) |
Merge the data from another mesh into this one. | |
bool | is_init () const |
Return true if the mesh has been initialized. | |
const imesh_vertex_array_base & | vertices () const |
Access the vector of vertices. | |
imesh_vertex_array_base & | vertices () |
template<unsigned int d> | |
const imesh_vertex_array< d > & | vertices () const |
Access the vector of vertices cast to a dimension. | |
template<unsigned int d> | |
imesh_vertex_array< d > & | vertices () |
const imesh_face_array_base & | faces () const |
Access the vector of faces. | |
imesh_face_array_base & | faces () |
void | set_vertices (vcl_auto_ptr< imesh_vertex_array_base > verts) |
Set the vertices. | |
void | set_faces (vcl_auto_ptr< imesh_face_array_base > faces) |
Set the faces. | |
bool | has_half_edges () const |
Returns true if the mesh has computed half edges. | |
const imesh_half_edge_set & | half_edges () const |
Return the half edge set. | |
void | build_edge_graph () |
Construct the half edges graph structure. | |
void | remove_edge_graph () |
Remove the half edge graph structure. | |
void | compute_vertex_normals () |
Compute vertex normals. | |
void | compute_vertex_normals_from_faces () |
Compute vertex normals using face normals. | |
void | compute_face_normals (bool norm=true) |
Compute face normals. | |
tex_coord_type | has_tex_coords () const |
Returns texture coordinate availability. | |
const vcl_vector< vgl_point_2d < double > > & | tex_coords () const |
Return the texture coordinates. | |
void | set_tex_coords (const vcl_vector< vgl_point_2d< double > > &tc) |
Set the texture coordinates. | |
void | set_tex_source (const vcl_string ts) |
set the texture sources. | |
const vcl_string & | tex_source () const |
const vcl_vector< bool > & | valid_tex_faces () const |
Return a vector indicating which faces have texture. | |
void | set_valid_tex_faces (const vcl_vector< bool > &valid) |
Set the vector indicating which faces have texture. | |
void | label_ccw_tex_faces_valid () |
Label all faces with positive (counter clockwise orientation) area as valid. | |
vgl_point_2d< double > | texture_map (unsigned int tri, double u, double v) const |
Map a barycentric coordinate (u,v) on triangle. | |
Protected Member Functions | |
vnl_matrix< double > | compute_mean (const vcl_vector< imesh_mesh > &meshes) |
compute and set the mean return the deviations matrix. | |
imesh_pca_mesh (const imesh_mesh &mesh) | |
Construct from a mesh with no variation. | |
Protected Attributes | |
vnl_vector< double > | std_devs_ |
vnl_matrix< double > | pc_ |
vcl_auto_ptr < imesh_vertex_array_base > | mean_verts_ |
vnl_vector< double > | params_ |
Principal Component Analysis on a set of mesh vertices.
Definition at line 25 of file imesh_pca.h.
enum imesh_mesh::tex_coord_type [inherited] |
This type indicates how texture coordinates are indexed.
ON_VERT is one coordinate per vertex ON_CORNER is one coordinate per half edge (i.e. corner)
Definition at line 112 of file imesh_mesh.h.
imesh_pca_mesh::imesh_pca_mesh | ( | ) | [inline] |
Default Constructor.
Definition at line 29 of file imesh_pca.h.
imesh_pca_mesh::imesh_pca_mesh | ( | const vcl_vector< imesh_mesh > & | meshes | ) |
Constructor from a vector of meshes with the same topology.
Definition at line 13 of file imesh_pca.cxx.
imesh_pca_mesh::imesh_pca_mesh | ( | const imesh_mesh & | mesh, |
const vnl_vector< double > & | mean, | ||
const vnl_vector< double > & | std_devs, | ||
const vnl_matrix< double > & | pc | ||
) |
Constructor from a mesh, mean, standard deviations, and PC matrix.
Definition at line 71 of file imesh_pca.cxx.
imesh_pca_mesh::imesh_pca_mesh | ( | const imesh_pca_mesh & | other | ) |
Copy Constructor.
Definition at line 82 of file imesh_pca.cxx.
imesh_pca_mesh::imesh_pca_mesh | ( | const imesh_mesh & | mesh | ) | [protected] |
Construct from a mesh with no variation.
Definition at line 108 of file imesh_pca.cxx.
void imesh_mesh::build_edge_graph | ( | ) | [inherited] |
Construct the half edges graph structure.
Definition at line 93 of file imesh_mesh.cxx.
void imesh_mesh::compute_face_normals | ( | bool | norm = true | ) | [inherited] |
Compute face normals.
If norm == false the vector lengths are twice the area of the face
Definition at line 183 of file imesh_mesh.cxx.
vnl_matrix< double > imesh_pca_mesh::compute_mean | ( | const vcl_vector< imesh_mesh > & | meshes | ) | [protected] |
compute and set the mean return the deviations matrix.
Definition at line 32 of file imesh_pca.cxx.
void imesh_mesh::compute_vertex_normals | ( | ) | [inherited] |
Compute vertex normals.
Definition at line 108 of file imesh_mesh.cxx.
void imesh_mesh::compute_vertex_normals_from_faces | ( | ) | [inherited] |
Compute vertex normals using face normals.
Definition at line 144 of file imesh_mesh.cxx.
const imesh_face_array_base& imesh_mesh::faces | ( | ) | const [inline, inherited] |
Access the vector of faces.
Definition at line 78 of file imesh_mesh.h.
imesh_face_array_base& imesh_mesh::faces | ( | ) | [inline, inherited] |
Definition at line 79 of file imesh_mesh.h.
const imesh_half_edge_set& imesh_mesh::half_edges | ( | ) | const [inline, inherited] |
Return the half edge set.
Definition at line 91 of file imesh_mesh.h.
bool imesh_mesh::has_half_edges | ( | ) | const [inline, inherited] |
Returns true if the mesh has computed half edges.
Definition at line 88 of file imesh_mesh.h.
tex_coord_type imesh_mesh::has_tex_coords | ( | ) | const [inline, inherited] |
Returns texture coordinate availability.
Definition at line 117 of file imesh_mesh.h.
void imesh_pca_mesh::init | ( | const vnl_vector< double > & | mean, |
const vnl_vector< double > & | std_devs, | ||
const vnl_matrix< double > & | pc | ||
) |
Initialize the PCA data (assuming mesh data is already set).
Use this to add PCA data after a mesh has be loaded from a file
Definition at line 116 of file imesh_pca.cxx.
bool imesh_mesh::is_init | ( | ) | const [inline, inherited] |
Return true if the mesh has been initialized.
Definition at line 57 of file imesh_mesh.h.
void imesh_mesh::label_ccw_tex_faces_valid | ( | ) | [inherited] |
Label all faces with positive (counter clockwise orientation) area as valid.
This requirement refers to the texture map coordinates
Definition at line 235 of file imesh_mesh.cxx.
const imesh_vertex_array_base& imesh_pca_mesh::mean_vertices | ( | ) | const [inline] |
Access the vector of mean vertices.
Definition at line 77 of file imesh_pca.h.
imesh_vertex_array_base& imesh_pca_mesh::mean_vertices | ( | ) | [inline] |
Definition at line 78 of file imesh_pca.h.
const imesh_vertex_array<d>& imesh_pca_mesh::mean_vertices | ( | ) | const [inline] |
Access the vector of mean vertices cast to a dimension.
Definition at line 82 of file imesh_pca.h.
imesh_vertex_array<d>& imesh_pca_mesh::mean_vertices | ( | ) | [inline] |
Definition at line 88 of file imesh_pca.h.
void imesh_mesh::merge | ( | const imesh_mesh & | other | ) | [inherited] |
Merge the data from another mesh into this one.
Duplicates are not removed
Definition at line 44 of file imesh_mesh.cxx.
unsigned int imesh_mesh::num_edges | ( | ) | const [inline, inherited] |
Return the number of edges.
Definition at line 50 of file imesh_mesh.h.
unsigned int imesh_mesh::num_faces | ( | ) | const [inline, inherited] |
Return the number of faces.
Definition at line 47 of file imesh_mesh.h.
unsigned int imesh_mesh::num_verts | ( | ) | const [inline, inherited] |
Return the number of vertices.
Definition at line 44 of file imesh_mesh.h.
imesh_pca_mesh & imesh_pca_mesh::operator= | ( | const imesh_pca_mesh & | other | ) |
Assignment operator.
Definition at line 93 of file imesh_pca.cxx.
const vnl_vector<double>& imesh_pca_mesh::params | ( | ) | const [inline] |
Access the params.
Definition at line 61 of file imesh_pca.h.
const vnl_matrix<double>& imesh_pca_mesh::principal_comps | ( | ) | const [inline] |
Access the principal components.
Definition at line 64 of file imesh_pca.h.
vnl_vector< double > imesh_pca_mesh::project | ( | const imesh_vertex_array_base & | verts | ) | const |
Project mesh vertices into the PCA parameter space.
Definition at line 199 of file imesh_pca.cxx.
void imesh_mesh::remove_edge_graph | ( | ) | [inline, inherited] |
Remove the half edge graph structure.
Definition at line 97 of file imesh_mesh.h.
void imesh_mesh::set_faces | ( | vcl_auto_ptr< imesh_face_array_base > | faces | ) | [inline, inherited] |
Set the faces.
Definition at line 85 of file imesh_mesh.h.
void imesh_pca_mesh::set_mean | ( | ) |
Reset all the PCA parameters to zero.
Returning to the mean mesh
Definition at line 185 of file imesh_pca.cxx.
void imesh_pca_mesh::set_param | ( | unsigned int | idx, |
double | param | ||
) |
Set an individual pca parameter.
This is done by incremental difference, errors may accumulate over many calls.
Definition at line 168 of file imesh_pca.cxx.
void imesh_pca_mesh::set_params | ( | const vnl_vector< double > & | p | ) |
Set the pca parameters.
Definition at line 138 of file imesh_pca.cxx.
void imesh_mesh::set_tex_coords | ( | const vcl_vector< vgl_point_2d< double > > & | tc | ) | [inherited] |
Set the texture coordinates.
Definition at line 79 of file imesh_mesh.cxx.
void imesh_mesh::set_tex_source | ( | const vcl_string | ts | ) | [inline, inherited] |
set the texture sources.
Definition at line 126 of file imesh_mesh.h.
void imesh_mesh::set_valid_tex_faces | ( | const vcl_vector< bool > & | valid | ) | [inherited] |
Set the vector indicating which faces have texture.
Definition at line 226 of file imesh_mesh.cxx.
void imesh_mesh::set_vertices | ( | vcl_auto_ptr< imesh_vertex_array_base > | verts | ) | [inline, inherited] |
Set the vertices.
Definition at line 82 of file imesh_mesh.h.
const vnl_vector<double>& imesh_pca_mesh::std_devs | ( | ) | const [inline] |
Access the standard deviations.
Definition at line 67 of file imesh_pca.h.
const vcl_vector<vgl_point_2d<double> >& imesh_mesh::tex_coords | ( | ) | const [inline, inherited] |
Return the texture coordinates.
Definition at line 120 of file imesh_mesh.h.
const vcl_string& imesh_mesh::tex_source | ( | ) | const [inline, inherited] |
Definition at line 127 of file imesh_mesh.h.
vgl_point_2d< double > imesh_mesh::texture_map | ( | unsigned int | tri, |
double | u, | ||
double | v | ||
) | const [inherited] |
Map a barycentric coordinate (u,v) on triangle.
tri | into texture space. |
Definition at line 208 of file imesh_mesh.cxx.
const vcl_vector<bool>& imesh_mesh::valid_tex_faces | ( | ) | const [inline, inherited] |
Return a vector indicating which faces have texture.
Definition at line 130 of file imesh_mesh.h.
const imesh_vertex_array_base& imesh_mesh::vertices | ( | ) | const [inline, inherited] |
Access the vector of vertices.
Definition at line 60 of file imesh_mesh.h.
imesh_vertex_array_base& imesh_mesh::vertices | ( | ) | [inline, inherited] |
Definition at line 61 of file imesh_mesh.h.
const imesh_vertex_array<d>& imesh_mesh::vertices | ( | ) | const [inline, inherited] |
Access the vector of vertices cast to a dimension.
Definition at line 65 of file imesh_mesh.h.
imesh_vertex_array<d>& imesh_mesh::vertices | ( | ) | [inline, inherited] |
Definition at line 71 of file imesh_mesh.h.
vcl_auto_ptr<imesh_vertex_array_base> imesh_pca_mesh::mean_verts_ [protected] |
Definition at line 102 of file imesh_pca.h.
vnl_vector<double> imesh_pca_mesh::params_ [protected] |
Definition at line 104 of file imesh_pca.h.
vnl_matrix<double> imesh_pca_mesh::pc_ [protected] |
Definition at line 101 of file imesh_pca.h.
vnl_vector<double> imesh_pca_mesh::std_devs_ [protected] |
Definition at line 100 of file imesh_pca.h.