Skip to content

Libs/Mesh/MeshWarper.h

Mesh warping capability. More...

Namespaces

Name
shapeworks
User usage reporting (telemetry)

Classes

Name
class shapeworks::MeshWarper

Detailed Description

Mesh warping capability.

The MeshWarper provides an object to warp meshes for surface reconstruction

Source code

```cpp

pragma once

include

include

include

include

namespace shapeworks {

enum class WarpMethod { Laplacian, Biharmonic };

class MeshWarper { public: void set_reference_mesh(vtkSmartPointer reference_mesh, const Eigen::MatrixXd& reference_particles, const Eigen::MatrixXd& landmarks = {});

bool generate_warp();

bool get_warp_available();

bool is_contour() const { return is_contour_; }

vtkSmartPointer build_mesh(const Eigen::MatrixXd& particles);

Eigen::MatrixXd extract_landmarks(vtkSmartPointer warped_mesh);

bool is_contour() { return this->is_contour_; }

std::map get_landmarks_map() const { return landmarks_map_; }

std::vector get_good_particle_indices() const { return good_particles_; }

const Eigen::MatrixXd& get_warp_matrix() const { return this->warp_; }

bool has_bad_particles() const { return this->bad_particle_count() > 0; }

vtkSmartPointer get_reference_mesh() { return this->reference_mesh_; }

const Eigen::MatrixXd& get_reference_particles() const { return this->reference_particles_; }

void set_warp_method(WarpMethod method) { warp_method_ = method; }

WarpMethod get_warp_method() const { return warp_method_; }

int get_num_warp_vertices() const;

protected: virtual void update_progress(float p) {}

private: bool check_warp_ready();

void add_particle_vertices(Eigen::MatrixXd& vertices);

Eigen::MatrixXd remove_bad_particles(const Eigen::MatrixXd& particles);

void split_cell_on_edge(int cell_id, int new_vertex, int v0, int v1, std::vector>& new_triangles);

void find_good_particles();

bool find_landmarks_vertices_on_ref_mesh();

bool generate_warp_matrix(Eigen::MatrixXd target_vertices, Eigen::MatrixXi target_faces, const Eigen::MatrixXd& references_vertices, Eigen::MatrixXd& warp);

vtkSmartPointer warp_mesh(const Eigen::MatrixXd& points);

size_t bad_particle_count() const { return size_t(reference_particles_.rows()) - good_particles_.size(); }

void diagnose_biharmonic_failure(const Eigen::MatrixXd& TV, const Eigen::MatrixXi& TF, const std::vector>& S, int k);

bool generate_laplacian_warp(const Eigen::MatrixXd& V, const Eigen::MatrixXi& F, const Eigen::MatrixXd& control_points);

vtkSmartPointer warp_mesh_laplacian(const Eigen::MatrixXd& points);

// Members Eigen::MatrixXi faces_; Eigen::MatrixXd vertices_; Eigen::MatrixXd warp_; Eigen::MatrixXd landmarks_points_;

std::vector good_particles_;

bool needs_warp_ = true;

bool warp_available_ = false;

std::map landmarks_map_; // map the landmarks id (Key) to the vertex(point) id (Value) belonging to the // clean Reference mesh vtkSmartPointer incoming_reference_mesh_; vtkSmartPointer reference_mesh_; Eigen::MatrixXd reference_particles_; bool is_contour_ = false;

WarpMethod warp_method_ = WarpMethod::Biharmonic;

igl::min_quad_with_fixed_data mqwf_data_; Eigen::MatrixXd laplacian_rhs_;
Eigen::MatrixXd laplacian_vertices_;
Eigen::VectorXi laplacian_handles_;
Eigen::SparseMatrix handle_map_;
Eigen::MatrixXd handle_default_;
bool laplacian_ready_ = false; }; } // namespace shapeworks ```


Updated on 2026-03-31 at 16:02:11 +0000