Skip to content

Commit

Permalink
Merge 01d7d0f into e9e33b3
Browse files Browse the repository at this point in the history
  • Loading branch information
dsieger committed Jul 6, 2023
2 parents e9e33b3 + 01d7d0f commit 7a3f6e6
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 313 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Expand Up @@ -12,11 +12,11 @@ This project aims to adhere to [Semantic Versioning](https://semver.org/spec/v2.

### Added

- Functions `setup_laplace_matrix()` and `setup_mass_matrix()` compute those
two matrices for both triangle meshes and general polygon meshes.
- Functions `setup_laplace_matrix()` and `setup_mass_matrix()` compute those
two matrices for both triangle meshes and general polygon meshes.
The general case is based on the paper Bunge et al, "Polygon Laplacian made simple",
Eurographics 2020.
- Smoothing, parameterization, and fairing are now implemented based on
- Smoothing, parameterization, and fairing are now implemented based on
sparse Laplacian matrices, which generalizes to general polygon meshes.
- Add `PMP_STRICT_COMPILATION` CMake option to control treating warnings as errors. Default: On.
- Add function `flip_faces()` to reverse face orientation in a mesh (#123)
Expand All @@ -25,6 +25,7 @@ This project aims to adhere to [Semantic Versioning](https://semver.org/spec/v2.

### Changed

- `SurfaceMeshGL` renamed to `Renderer` and de-coupled from `SurfaceMesh`
- Replace `triangle_area(Face)` by `face_area(Face)`, which now
supports general polygons. `surface_area(SurfaceMesh)` now also
works for general polygon meshes.
Expand Down
8 changes: 4 additions & 4 deletions examples/MeshProcessingViewer.cpp
Expand Up @@ -158,23 +158,23 @@ void MeshProcessingViewer::process_imgui()
{
curvature(mesh_, Curvature::mean, 1, true, true);
curvature_to_texture_coordinates(mesh_);
mesh_.use_cold_warm_texture();
renderer_.use_cold_warm_texture();
update_mesh();
set_draw_mode("Texture");
}
if (ImGui::Button("Gauss Curvature"))
{
curvature(mesh_, Curvature::gauss, 1, true, true);
curvature_to_texture_coordinates(mesh_);
mesh_.use_cold_warm_texture();
renderer_.use_cold_warm_texture();
update_mesh();
set_draw_mode("Texture");
}
if (ImGui::Button("Abs. Max. Curvature"))
{
curvature(mesh_, Curvature::max_abs, 1, true, true);
curvature_to_texture_coordinates(mesh_);
mesh_.use_cold_warm_texture();
renderer_.use_cold_warm_texture();
update_mesh();
set_draw_mode("Texture");
}
Expand Down Expand Up @@ -416,7 +416,7 @@ void MeshProcessingViewer::mouse(int button, int action, int mods)

// setup texture coordinates for visualization
distance_to_texture_coordinates(mesh_);
mesh_.use_checkerboard_texture();
renderer_.use_checkerboard_texture();
update_mesh();
set_draw_mode("Texture");
}
Expand Down
6 changes: 3 additions & 3 deletions examples/curvature.cpp
Expand Up @@ -32,23 +32,23 @@ void Viewer::process_imgui()
{
curvature(mesh_, Curvature::mean, 1, true, true);
curvature_to_texture_coordinates(mesh_);
mesh_.use_cold_warm_texture();
renderer_.use_cold_warm_texture();
update_mesh();
set_draw_mode("Texture");
}
if (ImGui::Button("Gauss Curvature"))
{
curvature(mesh_, Curvature::gauss, 1, true, true);
curvature_to_texture_coordinates(mesh_);
mesh_.use_cold_warm_texture();
renderer_.use_cold_warm_texture();
update_mesh();
set_draw_mode("Texture");
}
if (ImGui::Button("Abs. Max. Curvature"))
{
curvature(mesh_, Curvature::max_abs, 1, true, true);
curvature_to_texture_coordinates(mesh_);
mesh_.use_cold_warm_texture();
renderer_.use_cold_warm_texture();
update_mesh();
set_draw_mode("Texture");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/fairing.cpp
Expand Up @@ -36,7 +36,7 @@ void Viewer::process_imgui()
curvature(mesh_, Curvature::mean, 1, true, true);
curvature_to_texture_coordinates(mesh_);
update_mesh();
mesh_.use_cold_warm_texture();
renderer_.use_cold_warm_texture();
set_draw_mode("Texture");
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/parameterization.cpp
Expand Up @@ -62,7 +62,7 @@ void Viewer::process_imgui()
std::cerr << e.what() << std::endl;
return;
}
mesh_.use_checkerboard_texture();
renderer_.use_checkerboard_texture();
set_draw_mode("Texture");
update_mesh();
}
Expand All @@ -79,7 +79,7 @@ void Viewer::process_imgui()
std::cerr << e.what() << std::endl;
return;
}
mesh_.use_checkerboard_texture();
renderer_.use_checkerboard_texture();
set_draw_mode("Texture");
update_mesh();
}
Expand All @@ -90,7 +90,7 @@ void Viewer::draw(const std::string& draw_mode)
{
// normal mesh draw
glViewport(0, 0, width(), height());
mesh_.draw(projection_matrix_, modelview_matrix_, draw_mode);
renderer_.draw(projection_matrix_, modelview_matrix_, draw_mode);

// draw uv layout
{
Expand All @@ -106,7 +106,7 @@ void Viewer::draw(const std::string& draw_mode)
mat4 M = mat4::identity();

// draw mesh once more
mesh_.draw(P, M, "Texture Layout");
renderer_.draw(P, M, "Texture Layout");
}

// reset viewport
Expand Down
2 changes: 1 addition & 1 deletion examples/smoothing.cpp
Expand Up @@ -37,7 +37,7 @@ void Viewer::process_imgui()
curvature(mesh_, Curvature::mean, 1, true, true);
curvature_to_texture_coordinates(mesh_);
update_mesh();
mesh_.use_cold_warm_texture();
renderer_.use_cold_warm_texture();
set_draw_mode("Texture");
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/pmp/visualization/MeshViewer.cpp
Expand Up @@ -15,7 +15,7 @@
namespace pmp {

MeshViewer::MeshViewer(const char* title, int width, int height, bool showgui)
: TrackballViewer(title, width, height, showgui)
: TrackballViewer(title, width, height, showgui), renderer_(mesh_)
{
// setup draw modes
clear_draw_modes();
Expand Down Expand Up @@ -65,14 +65,14 @@ void MeshViewer::load_mesh(const char* filename)
<< " vertices, " << mesh_.n_faces() << " faces\n";

filename_ = filename;
mesh_.set_crease_angle(crease_angle_);
renderer_.set_crease_angle(crease_angle_);
}

void MeshViewer::load_matcap(const char* filename)
{
try
{
mesh_.load_matcap(filename);
renderer_.load_matcap(filename);
}
catch (const IOException& e)
{
Expand All @@ -88,7 +88,7 @@ void MeshViewer::load_texture(const char* filename, GLint format,
// load texture from file
try
{
mesh_.load_texture(filename, format, min_filter, mag_filter, wrap);
renderer_.load_texture(filename, format, min_filter, mag_filter, wrap);
}
catch (const IOException& e)
{
Expand All @@ -99,10 +99,10 @@ void MeshViewer::load_texture(const char* filename, GLint format,
set_draw_mode("Texture");

// set material
mesh_.set_ambient(1.0);
mesh_.set_diffuse(0.9);
mesh_.set_specular(0.0);
mesh_.set_shininess(1.0);
renderer_.set_ambient(1.0);
renderer_.set_diffuse(0.9);
renderer_.set_specular(0.0);
renderer_.set_shininess(1.0);
}

void MeshViewer::drop(int count, const char** paths)
Expand Down Expand Up @@ -131,7 +131,7 @@ void MeshViewer::update_mesh()
radius_ = 0.5f * bb.size();

// re-compute face and vertex normals
mesh_.update_opengl_buffers();
renderer_.update_opengl_buffers();
}

void MeshViewer::process_imgui()
Expand All @@ -148,17 +148,17 @@ void MeshViewer::process_imgui()
ImGui::SliderFloat("Crease Angle", &crease_angle_, 0.0f, 180.0f,
"%.0f");
ImGui::PopItemWidth();
if (crease_angle_ != mesh_.crease_angle())
if (crease_angle_ != renderer_.crease_angle())
{
mesh_.set_crease_angle(crease_angle_);
renderer_.set_crease_angle(crease_angle_);
}
}
}

void MeshViewer::draw(const std::string& drawMode)
{
// draw mesh
mesh_.draw(projection_matrix_, modelview_matrix_, drawMode);
renderer_.draw(projection_matrix_, modelview_matrix_, drawMode);
}

void MeshViewer::keyboard(int key, int scancode, int action, int mods)
Expand Down
6 changes: 4 additions & 2 deletions src/pmp/visualization/MeshViewer.h
Expand Up @@ -4,7 +4,8 @@
#pragma once

#include "pmp/visualization/TrackballViewer.h"
#include "pmp/visualization/SurfaceMeshGL.h"
#include "pmp/SurfaceMesh.h"
#include "pmp/visualization/Renderer.h"

namespace pmp {

Expand Down Expand Up @@ -52,7 +53,8 @@ class MeshViewer : public TrackballViewer
Vertex pick_vertex(int x, int y);

protected:
SurfaceMeshGL mesh_; //!< the mesh
SurfaceMesh mesh_;
Renderer renderer_;
std::string filename_; //!< the current file
float crease_angle_;
};
Expand Down

0 comments on commit 7a3f6e6

Please sign in to comment.