setup for curvature flow class

This commit is contained in:
konstantinos katrioplas 2017-07-05 12:20:24 +03:00
parent ab673f61ea
commit 3c5ca4d88d
4 changed files with 211 additions and 0 deletions

View File

@ -0,0 +1,40 @@
#include <iostream>
#include <fstream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/smoothing.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
int main(int argc, char* argv[]){
const char* filename = "data/curved_polygon.off";
std::ifstream input(filename);
Mesh mesh;
if (!input || !(input >> mesh) || mesh.is_empty()) {
std::cerr << "Not a valid .off file." << std::endl;
return 1;
}
CGAL::Polygon_mesh_processing::curvature_flow(mesh);
std::ofstream output("data/curved_polygon_smoothed.off");
output << mesh;
output.close();
return 0;
}

View File

@ -0,0 +1,60 @@
#ifndef CURVATURE_FLOW_IMPL_H
#define CURVATURE_FLOW_IMPL_H
namespace CGAL {
namespace Polygon_mesh_processing {
namespace internal {
template<typename PolygonMesh, typename VertexPointMap>
class Curvature_flow
{
public:
Curvature_flow(PolygonMesh& pmesh, VertexPointMap& vpmap) : mesh_(pmesh), vpmap_(vpmap)
{}
// k = div n
// cot a = v1 * v2 / v1 x v2
private:
PolygonMesh& mesh_;
VertexPointMap& vpmap_;
};
} // internal
} // Polygon_mesh_processing
} // CGAL
#endif // CURVATURE_FLOW_IMPL_H

View File

@ -5,6 +5,7 @@
#include <CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/smoothing_impl.h>
#include <CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/curvature_flow_impl.h>
#include <CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h>
#include <CGAL/Polygon_mesh_processing/internal/named_function_params.h>
@ -128,6 +129,27 @@ void compatible_remeshing(PolygonMesh& pmesh, const FaceRange& faces, const Edg
template<typename PolygonMesh, typename NamedParameters>
void curvature_flow(PolygonMesh& pmesh, NamedParameters& np)
{
using boost::choose_param;
using boost::get_param;
//vpmap
typedef typename GetVertexPointMap<PolygonMesh, NamedParameters>::const_type VertexPointMap;
VertexPointMap vpmap = choose_param(get_param(np, internal_np::vertex_point),
get_const_property_map(CGAL::vertex_point, pmesh));
internal::Curvature_flow<PolygonMesh, VertexPointMap> curvature_remesher(pmesh, vpmap);
}
void curvature_flow(PolygonMesh& pmesh)
{
curvature_flow(pmesh, parameters::all_default());
}
} // namespace Polygon_mesh_processing

View File

@ -0,0 +1,89 @@
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/smoothing.h>
#define CGAL_PMP_REMESHING_VERBOSE
#define CGAL_TEST_COMP_REMESHING_OUTPUT
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
int main(int argc, char* argv[]){
std::string filename;
std::ifstream input;
Mesh mesh;
#ifdef CGAL_TEST_COMP_REMESHING_OUTPUT
std::ofstream output;
#endif
std::vector<std::string> filenames = {
"data/curved_polygon",
/*"data/polygon",
"data/polygon3D",
"data/blobby_3cc",
"data/cube_quad",
"data/elephant",
"data/degenerate_polygon",
"data/sneaky_degenerate_polygon",
"data/joint_refined",
"data/mannequin-devil",
"data/mech-holes-shark",
"data/non_manifold_vertex",
"data/overlapping_triangles",
"data/tetra1",
"data/tetra2",
"data/tetra3",
"data/tetra4",
"data/two_tris_collinear",
"data/U"*/
};
for(auto i=0; i!= filenames.size(); ++i)
{
filename = filenames[i]+".off";
input.open(filename);
#ifdef CGAL_PMP_REMESHING_VERBOSE
std::cout<<"case: "<< filename << std::endl;
#endif
if (!input || !(input >> mesh) || mesh.is_empty()) {
std::cerr << "Not a valid .off file." << std::endl;
return 1;
}
input.close();
CGAL::Polygon_mesh_processing::curvature_flow(mesh);
#ifdef CGAL_TEST_COMP_REMESHING_OUTPUT
output.open(filenames[i]+"_smoothed"+".off");
output << mesh;
output.close();
#endif
}
return 0;
}