Renaming and cleaning

This commit is contained in:
iyaz 2013-05-29 15:08:12 +03:00
parent bbc2bf4e68
commit bb67aa6d0a
8 changed files with 135 additions and 26 deletions

View File

@ -1,5 +1,5 @@
#ifndef CGAL_HOLE_FILLING_FAIR_H
#define CGAL_HOLE_FILLING_FAIR_H
#ifndef CGAL_HOLE_FILLING_FAIR_POLYHEDRON_3_H
#define CGAL_HOLE_FILLING_FAIR_POLYHEDRON_3_H
#include <map>
#include <set>
@ -246,4 +246,4 @@ void fair(Polyhedron& poly,
//}
}//namespace CGAL
#endif //CGAL_HOLE_FILLING_FAIR_H
#endif //CGAL_HOLE_FILLING_FAIR_POLYHEDRON_3_H

View File

@ -0,0 +1,111 @@
#ifndef CGAL_HOLE_FILLING_FILL_HOLE_CONNECTOR
#define CGAL_HOLE_FILLING_FILL_HOLE_CONNECTOR
#include <CGAL/internal/Fair_Polyhedron_3.h>
#include <CGAL/internal/Refine_Polyhedron_3.h>
#include <CGAL/internal/Triangulate_hole_Polyhedron_3.h>
#include <CGAL/trace.h>
#include <boost/function_output_iterator.hpp>
#include <vector>
#include <set>
#include <map>
namespace CGAL {
namespace internal {
struct Nop_functor {
template<class T>
void operator()(const T& t) const {}
};
// Connector class to triangulate - refine - fair holes on Polyhedron_3
template<class Polyhedron>
class Fill_hole_Polyhedron_3 {
typedef typename Polyhedron::Traits::Point_3 Point_3;
typedef typename Polyhedron::Vertex_handle Vertex_handle;
typedef typename Polyhedron::Halfedge_handle Halfedge_handle;
typedef typename Polyhedron::Facet_handle Facet_handle;
typedef typename Polyhedron::Halfedge_around_facet_circulator Halfedge_around_facet_circulator;
typedef typename Polyhedron::Halfedge_around_vertex_circulator Halfedge_around_vertex_circulator;
private:
void average_length(Polyhedron& poly, Vertex_handle vh, std::map<Vertex_handle, double>& scale_attribute)
{
const Point_3& vp = vh->point();
Halfedge_around_vertex_circulator circ(vh->vertex_begin()), done(circ);
int deg = 0;
double sum = 0;
do {
const Point_3& vq = circ->opposite()->vertex()->point();
sum += std::sqrt(CGAL::squared_distance(vp, vq));
++deg;
++circ;
} while(circ != done);
scale_attribute[vh] = sum/deg;
}
void get_boundary_vertices(Polyhedron& poly, Halfedge_handle it, std::set<Vertex_handle>& boundary_vertices) {
Halfedge_around_facet_circulator circ(it), done(circ);
do{
boundary_vertices.insert(circ->vertex());
} while (++circ != done);
}
public:
template<class OutputIterator>
void triangulate_and_refine_hole(Polyhedron& poly, Halfedge_handle it, double alpha, OutputIterator output)
{
if(! it->is_border()){ return; }
// compute scale_attribute before triangulation
std::map<Vertex_handle, double> scale_attribute;
Halfedge_around_facet_circulator circ(it), done(circ);
do{
average_length(poly, circ->vertex(), scale_attribute);
} while (++circ != done);
// Triangulate
std::set<Facet_handle> facets;
triangulate_hole(poly, it, std::inserter(facets, facets.begin()));
// Refine
internal::Refine_Polyhedron_3<Polyhedron> refine_functor(alpha);
refine_functor(poly, scale_attribute, facets);
std::copy(facets.begin(), facets.end(), output);
}
template<class SparseLinearSolver, class WeightCalculator>
void triangulate_refine_and_fair
(Polyhedron& poly, Halfedge_handle it, double alpha, WeightCalculator weight_calculator)
{
if(! it->is_border()){ return; }
// save boundary vertices before triangulation
std::set<Vertex_handle> boundary_vertices;
get_boundary_vertices(poly, it, boundary_vertices);
//Triangulate and refine
std::vector<Facet_handle> facets;
triangulate_and_refine_hole(poly, it, alpha, std::back_inserter(facets));
// get interior vertices
std::set<Vertex_handle> interior_vertices;
for(std::vector<Facet_handle>::iterator it = facets.begin(); it != facets.end(); ++it) {
Halfedge_around_facet_circulator circ = (*it)->facet_begin();
do {
if(boundary_vertices.find(circ->vertex()) == boundary_vertices.end()) {
interior_vertices.insert(circ->vertex());
}
} while(++circ != (*it)->facet_begin());
}
CGAL_TRACE_STREAM << "before fair |boundary vertices| = " << boundary_vertices.size() << std::endl;
CGAL_TRACE_STREAM << "before fair |interior vertices| = " << interior_vertices.size() << std::endl;
// Fair
fair<SparseLinearSolver>(poly, interior_vertices, weight_calculator);
}
};
}//namespace internal
}//namespace CGAL
#endif // CGAL_HOLE_FILLING_FILL_HOLE_CONNECTOR

View File

@ -1,5 +1,5 @@
#ifndef CGAL_HOLE_FILLING_REFINE_H
#define CGAL_HOLE_FILLING_REFINE_H
#ifndef CGAL_HOLE_FILLING_REFINE_POLYHEDRON_3_H
#define CGAL_HOLE_FILLING_REFINE_POLYHEDRON_3_H
#include <cmath>
#include <map>
#include <set>
@ -148,4 +148,4 @@ public:
}//namespace internal
}//namespace CGAL
#endif //CGAL_HOLE_FILLING_REFINE_H
#endif //CGAL_HOLE_FILLING_REFINE_POLYHEDRON_3_H

View File

@ -1,5 +1,5 @@
#ifndef CGAL_HOLE_FILLING_SMOOTH_H
#define CGAL_HOLE_FILLING_SMOOTH_H
#ifndef CGAL_HOLE_FILLING_SMOOTH_POLYHEDRON_3_H
#define CGAL_HOLE_FILLING_SMOOTH_POLYHEDRON_3_H
// going to be moved some place more relevant
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/properties_Polyhedron_3.h>
@ -9,7 +9,7 @@
namespace CGAL {
// simple laplacian smoothing
// simple Laplacian smoothing
template<class WeightCalculator, class Polyhedron, class InputIterator>
void smooth( Polyhedron& polyhedron,
InputIterator vertex_begin,
@ -17,8 +17,6 @@ void smooth( Polyhedron& polyhedron,
WeightCalculator weight_calculator = WeightCalculator()
)
{
typedef typename boost::graph_traits<Polyhedron>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<Polyhedron>::edge_descriptor edge_descriptor;
typedef typename boost::graph_traits<Polyhedron>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<Polyhedron>::in_edge_iterator in_edge_iterator;
typedef typename Polyhedron::Traits::Point_3 Point;

View File

@ -1,17 +1,19 @@
#ifndef CGAL_HOLE_FILLING_TRIANGULATE_H
#define CGAL_HOLE_FILLING_TRIANGULATE_H
#ifndef CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYHEDRON_3_H
#define CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYHEDRON_3_H
#include <limits>
#include <map>
#include <set>
#include <vector>
#include <CGAL/assertions.h>
#include <CGAL/Mesh_3/dihedral_angle_3.h>
namespace CGAL {
namespace internal {
template<class Polyhedron>
class Triangulate_Hole_Polyhedron_3{
class Triangulate_hole_Polyhedron_3{
// typedefs
typedef typename Polyhedron::Traits::Point_3 Point_3;
typedef typename Polyhedron::Halfedge_handle Halfedge_handle;
@ -196,9 +198,8 @@ public:
void operator()(Polyhedron& poly, Halfedge_handle it) {
triangulate(poly, it, dummy_inserter());
}
};
}//namespace internal
}//namespace CGAL
#endif //CGAL_HOLE_FILLING_TRIANGULATE_H
#endif //CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYHEDRON_3_H

View File

@ -1,6 +1,5 @@
#ifndef CGAL_FILL_HOLE_H
#define CGAL_FILL_HOLE_H
#ifndef CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYLINE_H
#define CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYLINE_H
#include <CGAL/Mesh_3/dihedral_angle_3.h>
#include <CGAL/utility.h>
@ -8,9 +7,10 @@
#include <limits>
namespace CGAL {
namespace internal {
template <typename K>
class Fill_hole {
class Triangulate_hole_polyline {
public:
typedef typename K::Point_3 Point_3;
typedef std::vector<Point_3> Polyline_3;
@ -156,6 +156,7 @@ public:
}
};
} // namespace internal
/*!
Creates triangles to fill the hole defined by points in the range `(pbegin,pend)`.
@ -170,7 +171,7 @@ fill_hole(InputIterator pbegin, InputIterator pend,
OutputIterator out)
{
typedef typename CGAL::Kernel_traits< typename std::iterator_traits<InputIterator>::value_type>::Kernel Kernel;
typedef Fill_hole<Kernel> Fill;
typedef CGAL::internal::Triangulate_hole_polyline<Kernel> Fill;
typename Fill::Polyline_3 P(pbegin, pend);
typename Fill::Polyline_3 Q(qbegin, qend);
if(P.front() != P.back()){
@ -193,7 +194,7 @@ fill_hole(InputIterator pbegin, InputIterator pend,
OutputIterator out)
{
typedef typename CGAL::Kernel_traits< typename std::iterator_traits<InputIterator>::value_type>::Kernel Kernel;
typedef Fill_hole<Kernel> Fill;
typedef CGAL::internal::Triangulate_hole_polyline<Kernel> Fill;
typename Fill::Polyline_3 P(pbegin, pend);
typename Fill::Polyline_3 Q;
if(P.front() != P.back()){
@ -205,4 +206,4 @@ fill_hole(InputIterator pbegin, InputIterator pend,
} // namespace CGAL
#endif // CGAL_FILL_HOLE_H
#endif // CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYLINE_H

View File

@ -9,7 +9,6 @@
#include "ui_Hole_filling_widget.h"
#include "Polyhedron_type.h"
//#include <CGAL/Fill_hole.h>
#include <CGAL/Fill_hole_Polyhedron_3.h>
#include <QTime>

View File

@ -6,9 +6,8 @@
#include "ui_Smoothing_fairing_widget.h"
#include "Polyhedron_type.h"
//#include <CGAL/Fill_hole.h>
#include <CGAL/Fill_hole_Polyhedron_3.h>
#include <CGAL/internal/Smooth.h>
#include <CGAL/internal/Smooth_Polyhedron_3.h>
#include <QTime>
#include <QAction>