Output concept and model documentation improved

This commit is contained in:
Ivo Vigan 2014-07-30 15:53:56 +02:00
parent 01ef3c11a0
commit 3103565a04
5 changed files with 113 additions and 96 deletions

View File

@ -8,9 +8,9 @@ shape in a versatile way.
\cgalHasModel `CGAL::List_output<Tr>`
\cgalHasModel `CGAL::Off_output<Tr>`
\cgalHasModel `CGAL::Tds_output<Tr>`
\cgalHasModel `CGAL::List_output<Kernel, Output_Vertex_Iterator, Output_Edge_Iterator>`
\cgalHasModel `CGAL::Off_output<Kernel>`
\cgalHasModel `CGAL::Tds_output<Kernel>`
*/
@ -18,45 +18,14 @@ shape in a versatile way.
class OutputModule {
public:
/// \name Types
/// @{
/*!
Output_Iterator for accessing the isolated vertices.
Extracts the solid edges and vertices from the `Reconstruction_simplification_2` module.
\param rt2 The `Reconstruction_triangulation_2` from which the solid edges and vertices are extracted.
\param nb_ignore The number of verticess to be ignored in the output.
*/
typedef unspecified_type Output_Vertex_Iterator;
/*!
Output_Iterator for accessing the reconstructed edges.
*/
typedef unspecified_type Output_Edge_Iterator;
/// @}
/// \name Operations
/// @{
/*!
Returns an Output_Vertex_Iterator pointing to the first vertex.
*/
Output_Vertex_Iterator vertices_start();
/*!
Returns an Output_Vertex_Iterator pointing beyond the last vertex.
*/
Output_Vertex_Iterator vertices_beyond();
/*!
Returns an Output_Edge_Iterator pointing to the first edge.
*/
Output_Edge_Iterator edges_start();
/*!
Returns an Output_Edge_Iterator pointing beyond the last edge.
*/
Output_Edge_Iterator edges_beyond();
void store_marked_elements(Rt_2& rt2, int nb_ignore);
}; /* end OutputModule */

View File

@ -43,16 +43,24 @@ namespace CGAL {
\brief The class `List_output` is a model for the `OutputModule` concept.
\details It returns Output-iterators which allow iterating over both the
isolated vertices and the edges of the reconstructed shape
\details It takes two `Output-Iterators`, one for storing the
isolated points and one for storing the edges of the reconstructed shape.
\tparam Kernel is the geometric kernel, used for the reconstruction and
simplification task.
\tparam Output_Vertex_Iterator The `Output-Iterator` type for storing the points
\tparam Output_Edge_Iterator The `Output-Iterator` type for storing the
edges (as Segments).
*/
template<class Kernel, class Output_Vertex_Iterator, class Output_Edge_Iterator>
class List_output {
public:
/// \cond SKIP_IN_MANUAL
typedef typename Kernel::FT FT;
typedef typename Kernel::Point_2 Point;
typedef typename Kernel::Segment_2 Segment;
@ -74,49 +82,44 @@ public:
private:
Output_Vertex_Iterator m_v_it;
Output_Edge_Iterator m_e_it;
public:
List_output(Output_Vertex_Iterator v_it, Output_Edge_Iterator e_it) :
m_v_it(v_it), m_e_it(e_it) { }
void store_marked_vertices(Rt_2& rt2) {
for (Vertex_iterator vi = rt2.vertices_begin();
vi != rt2.vertices_end(); ++vi)
{
bool incident_edges_have_sample = false;
typename Rt_2::Edge_circulator start = rt2.incident_edges(vi);
void store_marked_vertices(Rt_2& rt2) {
typename Rt_2::Edge_circulator cur = start;
for (Vertex_iterator vi = rt2.vertices_begin();
vi != rt2.vertices_end(); ++vi)
{
bool incident_edges_have_sample = false;
typename Rt_2::Edge_circulator start = rt2.incident_edges(vi);
do {
if (!rt2.is_ghost(*cur)) {
incident_edges_have_sample = true;
break;
}
++cur;
} while (cur != start);
typename Rt_2::Edge_circulator cur = start;
if (!incident_edges_have_sample) {
if ((*vi).has_sample_assigned()) {
Point p = (*vi).point();
*m_v_it = p;
m_v_it++;
}
}
}
}
do {
if (!rt2.is_ghost(*cur)) {
incident_edges_have_sample = true;
break;
}
++cur;
} while (cur != start);
if (!incident_edges_have_sample) {
if ((*vi).has_sample_assigned()) {
Point p = (*vi).point();
*m_v_it = p;
m_v_it++;
}
}
}
}
void store_marked_edges(Rt_2& rt2, int nb_ignore) {
MultiIndex mindex;
for (Finite_edges_iterator ei = rt2.finite_edges_begin(); ei != rt2.finite_edges_end(); ++ei)
{
void store_marked_edges(Rt_2& rt2, int nb_ignore) {
MultiIndex mindex;
for (Finite_edges_iterator ei = rt2.finite_edges_begin(); ei != rt2.finite_edges_end(); ++ei)
{
Edge edge = *ei;
if (rt2.is_ghost(edge)) continue;
FT value = rt2.get_edge_relevance(edge); // >= 0
mindex.insert(Reconstruction_edge_2(edge, value));
}
}
int nb_remove = (std::min)(nb_ignore, int(mindex.size()));
@ -133,15 +136,42 @@ public:
(mindex.template get<0>()).erase(pedge);
Segment s(pedge.source()->point(), pedge.target()->point());
//edges.push_back(s);
*m_e_it = s;
*m_e_it = s;
m_e_it++;
}
}
}
void store_marked_elements(Rt_2& rt2, int nb_ignore) {
store_marked_vertices(rt2);
store_marked_edges(rt2, nb_ignore);
/// \endcond
public:
/// \name Creation
/// @{
/*!
Instantiates a new List_output object
for two given Output_Iterators.
\param v_it An Output_Vertex_Iterator for storing the points.
\param e_it An Output_Edge_Iterator for storing the edges (as Segments).
*/
List_output(Output_Vertex_Iterator v_it, Output_Edge_Iterator e_it) :
m_v_it(v_it), m_e_it(e_it) { }
/// @}
/*!
Extracts the solid edges and vertices from the `Reconstruction_simplification_2` module.
\param rt2 The `Reconstruction_triangulation_2` from which the solid edges and vertices are extracted.
\param nb_ignore The number of verticess to be ignored in the output.
*/
void store_marked_elements(Rt_2& rt2, int nb_ignore) {
store_marked_vertices(rt2);
store_marked_edges(rt2, nb_ignore);
}
};

View File

@ -1,10 +1,3 @@
/*
* Off_output.h
*
* Created on: Jul 10, 2014
* Author: ivovigan
*/
#ifndef OFF_OUTPUT_H_
#define OFF_OUTPUT_H_
@ -55,6 +48,10 @@ of the reconstructed shape via an std::ostream object.
*/
template<class Kernel>
class Off_output {
/// \cond SKIP_IN_MANUAL
public:
typedef Reconstruction_triangulation_2<Kernel> Rt_2;
typedef typename Rt_2::Triangulation_data_structure Tds_2;
@ -100,10 +97,20 @@ private:
}
/// \endcond
public:
Off_output() : list_output(Point_it(isolated_points), Edge_it(edges)) { }
/*!
Extracts the solid edges and vertices from the `Reconstruction_simplification_2` module.
\param rt2 The `Reconstruction_triangulation_2` from which the solid edges and vertices are extracted.
\param nb_ignore The number of verticess to be ignored in the output.
*/
void store_marked_elements(Rt_2& rt2, int nb_ignore) {
list_output.store_marked_elements(rt2, nb_ignore);
}

View File

@ -49,7 +49,6 @@
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/member.hpp>
#define EPS 1e-15
namespace CGAL {

View File

@ -1,10 +1,3 @@
/*
* Tds_output.h
*
* Created on: Jul 10, 2014
* Author: ivovigan
*/
#ifndef TDS_OUTPUT_H_
#define TDS_OUTPUT_H_
@ -52,6 +45,10 @@ namespace CGAL {
*/
template<class Kernel>
class Tds_output {
/// \cond SKIP_IN_MANUAL
public:
typedef Reconstruction_triangulation_2<Kernel> Rt_2;
typedef typename Kernel::FT FT;
@ -102,13 +99,28 @@ private:
}
}
/// \endcond
public:
void store_marked_elements(Rt_2& rt2, int nb_ignore) {
/*!
Extracts the solid edges and vertices from the `Reconstruction_simplification_2` module.
\param rt2 The `Reconstruction_triangulation_2` from which the solid edges and vertices are extracted.
\param nb_ignore The number of verticess to be ignored in the output.
*/
void store_marked_elements(Rt_2& rt2, int nb_ignore) {
m_rt2 = rt2;
mark_vertices();
mark_edges();
}
/*!
Allows accessing the `Reconstruction_triangulation_2` of the `Reconstruction_simplification_2` module.
\param rt2 The `Reconstruction_triangulation_2`.
*/
void extract_reconstruction_tds(Rt_2& rt2) {
rt2 = m_rt2;
}