add new compile target for viewer
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
//exmaple include hedder
|
||||
#ifndef EXAMPLE_INCLUDE_HPP
|
||||
#define EXAMPLE_INCLUDE_HPP
|
||||
|
||||
|
||||
|
||||
#endif // EXAMPLE_INCLUDE_HPP
|
||||
@@ -1,15 +1,16 @@
|
||||
#pragma once
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <Eigen/Dense>
|
||||
#include <igl/opengl/glfw/Viewer.h>
|
||||
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
|
||||
|
||||
|
||||
namespace mesh_utils {
|
||||
|
||||
template <typename Kernel>
|
||||
void cgal_to_eigen(CGAL::Surface_mesh<typename Kernel::Point_3>& mesh,
|
||||
Eigen::MatrixXd& V, Eigen::MatrixXi& F) {
|
||||
|
||||
CGAL::Polygon_mesh_processing::triangulate_faces(mesh);
|
||||
|
||||
V.resize(mesh.num_vertices(), 3);
|
||||
F.resize(mesh.num_faces(), 3);
|
||||
|
||||
@@ -17,7 +18,7 @@ void cgal_to_eigen(CGAL::Surface_mesh<typename Kernel::Point_3>& mesh,
|
||||
auto p = mesh.point(v);
|
||||
V.row(v.idx()) << p.x(), p.y(), p.z();
|
||||
}
|
||||
|
||||
|
||||
Eigen::Index face_idx = 0;
|
||||
for (auto f : mesh.faces()) {
|
||||
int vertex_count = 0;
|
||||
@@ -29,29 +30,12 @@ void cgal_to_eigen(CGAL::Surface_mesh<typename Kernel::Point_3>& mesh,
|
||||
face_idx++;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Kernel>
|
||||
void simple_visualize_mesh( CGAL::Surface_mesh<typename Kernel::Point_3>& mesh, bool triangulate = true) {
|
||||
if(!CGAL::is_triangle_mesh(mesh)) {
|
||||
std::cerr << "Warning: Mesh is not triangulated. Visualizer expects triangles.\n";
|
||||
|
||||
|
||||
if(triangulate){
|
||||
std::cout << "Triangulating mesh for visualization...\n";
|
||||
CGAL::Polygon_mesh_processing::triangulate_faces(mesh);
|
||||
}
|
||||
else{
|
||||
std::cout << " exit without visualizetion.\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
Eigen::MatrixXd V; Eigen::MatrixXi F;
|
||||
cgal_to_eigen<Kernel>(mesh, V, F);
|
||||
void simple_visualize_mesh(Eigen::MatrixXd& V, Eigen::MatrixXi& F) {
|
||||
igl::opengl::glfw::Viewer viewer;
|
||||
viewer.data().set_mesh(V, F);
|
||||
viewer.launch();
|
||||
}
|
||||
|
||||
// Zero-Copy Map für V (optional)
|
||||
template <typename Kernel>
|
||||
Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor>>
|
||||
@@ -60,5 +44,4 @@ get_vertex_map(CGAL::Surface_mesh<typename Kernel::Point_3>& mesh) {
|
||||
double* data = reinterpret_cast<double*>(&points[0][0]);
|
||||
return {data, static_cast<Eigen::Index>(points.size()), 3};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
11
code/include/viewer_utils.h
Normal file
11
code/include/viewer_utils.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <igl/opengl/glfw/Viewer.h>
|
||||
|
||||
namespace viewer_utils {
|
||||
|
||||
// Deklaration (Implementation in viewer.cpp)
|
||||
void simple_visualize(Eigen::MatrixXd& V, Eigen::MatrixXi& F);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user