mirror of https://github.com/CGAL/cgal
Enhanced operator(). Made the type of the coordinate index iterator a template parameter
Patch exceptionally accepted in master on a file not used by CGAL. Approved by the interim release manager.
This commit is contained in:
parent
aabd9dc557
commit
16151c46ff
|
|
@ -12,9 +12,6 @@
|
|||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
// Author(s): Efi Fogel <efif@post.tau.ac.il>
|
||||
// Naama mayer <naamamay@post.tau.ac.il>
|
||||
|
||||
|
|
@ -73,9 +70,6 @@ private:
|
|||
typedef typename Geometry_traits_2::Point_3 Point_3;
|
||||
typedef typename Geometry_traits_2::Vector_3 Vector_3;
|
||||
|
||||
/*! */
|
||||
typedef unsigned int* Coord_index_iter;
|
||||
|
||||
// Polyhedron types:
|
||||
typedef typename Polyhedron::Vertex_const_handle
|
||||
Polyhedron_vertex_const_handle;
|
||||
|
|
@ -94,9 +88,13 @@ private:
|
|||
typedef boost::is_same<typename Polyhedron::Plane_3, Vector_3>
|
||||
Polyhedron_has_normal;
|
||||
|
||||
typedef typename Polyhedron::HalfedgeDS HDS;
|
||||
typedef Polyhedron_incremental_builder_3<HDS> Builder;
|
||||
typedef typename Builder::size_type size_type;
|
||||
|
||||
/*! Transforms a (planar) facet into a normal */
|
||||
struct Normal_equation {
|
||||
template <class Facet>
|
||||
template <typename Facet>
|
||||
typename Facet::Plane_3 operator()(Facet& f) {
|
||||
typename Facet::Halfedge_handle h = f.halfedge();
|
||||
return CGAL::cross_product(h->next()->vertex()->point() -
|
||||
|
|
@ -130,7 +128,7 @@ private:
|
|||
}
|
||||
|
||||
/*! A point adder */
|
||||
template <class HDS, class PointIterator_3>
|
||||
template <typename HDS, typename PointIterator>
|
||||
class Point_adder {
|
||||
private:
|
||||
typedef Polyhedron_incremental_builder_3<HDS> Builder;
|
||||
|
|
@ -143,7 +141,7 @@ private:
|
|||
/*! Constructor */
|
||||
Point_adder(Builder& B) : m_B(B) {}
|
||||
|
||||
Polyhedron_vertex_handle operator()(PointIterator_3 pi)
|
||||
Polyhedron_vertex_handle operator()(PointIterator pi)
|
||||
{
|
||||
typedef typename HDS::Vertex Vertex;
|
||||
typedef typename Vertex::Point Point;
|
||||
|
|
@ -152,7 +150,7 @@ private:
|
|||
};
|
||||
|
||||
/*! Specialized point adder */
|
||||
template <class HDS> class Point_adder<HDS, Point_3*> {
|
||||
template <typename HDS> class Point_adder<HDS, Point_3*> {
|
||||
private:
|
||||
typedef Polyhedron_incremental_builder_3<HDS> Builder;
|
||||
Builder& m_B;
|
||||
|
|
@ -169,7 +167,7 @@ private:
|
|||
};
|
||||
|
||||
/*! */
|
||||
template <class PointIterator_3>
|
||||
template <typename PointIterator, typename CoordIndexIter>
|
||||
class Build_surface : public Modifier_base<typename Polyhedron::HalfedgeDS>
|
||||
{
|
||||
private:
|
||||
|
|
@ -180,22 +178,21 @@ private:
|
|||
typedef typename Polyhedron::HalfedgeDS HDS;
|
||||
typedef Polyhedron_incremental_builder_3<HDS> Builder;
|
||||
typedef typename Builder::size_type size_type;
|
||||
typedef unsigned int* Coord_index_iter;
|
||||
|
||||
/*! The begin iterator of the points */
|
||||
const PointIterator_3& m_points_begin;
|
||||
const PointIterator& m_points_begin;
|
||||
|
||||
/*! The end iterator of the points */
|
||||
const PointIterator_3& m_points_end;
|
||||
const PointIterator& m_points_end;
|
||||
|
||||
/*! The number of points */
|
||||
size_type m_num_points;
|
||||
|
||||
/*! The begin iterator of the indices */
|
||||
const Coord_index_iter& m_indices_begin;
|
||||
const CoordIndexIter& m_indices_begin;
|
||||
|
||||
/*! The end iterator of the indices */
|
||||
const Coord_index_iter& m_indices_end;
|
||||
const CoordIndexIter& m_indices_end;
|
||||
|
||||
/*! The number of facest */
|
||||
size_type m_num_facets;
|
||||
|
|
@ -204,21 +201,21 @@ private:
|
|||
size_type m_num_vertices_per_facet;
|
||||
|
||||
/*! The index of the marked vertex */
|
||||
unsigned int m_marked_vertex_index;
|
||||
size_type m_marked_vertex_index;
|
||||
|
||||
/*! The index of the marked edge */
|
||||
unsigned int m_marked_edge_index;
|
||||
size_type m_marked_edge_index;
|
||||
|
||||
/*! The index of the marked face */
|
||||
unsigned int m_marked_facet_index;
|
||||
size_type m_marked_facet_index;
|
||||
|
||||
public:
|
||||
/*! Constructor */
|
||||
Build_surface(const PointIterator_3& points_begin,
|
||||
const PointIterator_3& points_end,
|
||||
unsigned int num_points,
|
||||
const Coord_index_iter& indices_begin,
|
||||
const Coord_index_iter& indices_end,
|
||||
Build_surface(const PointIterator& points_begin,
|
||||
const PointIterator& points_end,
|
||||
size_type num_points,
|
||||
const CoordIndexIter& indices_begin,
|
||||
const CoordIndexIter& indices_end,
|
||||
size_type num_facets,
|
||||
size_type num_vertices_per_facet = 0) :
|
||||
m_points_begin(points_begin), m_points_end(points_end),
|
||||
|
|
@ -235,13 +232,13 @@ private:
|
|||
virtual ~Build_surface() {}
|
||||
|
||||
/*! Set the marked-vertex index */
|
||||
void set_marked_vertex_index(unsigned int id) {m_marked_vertex_index = id;}
|
||||
void set_marked_vertex_index(size_type id) {m_marked_vertex_index = id;}
|
||||
|
||||
/*! Set the marked-edge index */
|
||||
void set_marked_edge_index(unsigned int id) {m_marked_edge_index = id;}
|
||||
void set_marked_edge_index(size_type id) {m_marked_edge_index = id;}
|
||||
|
||||
/*! Set the marked-face index */
|
||||
void set_marked_facet_index(unsigned int id) {m_marked_facet_index = id;}
|
||||
void set_marked_facet_index(size_type id) {m_marked_facet_index = id;}
|
||||
|
||||
/*! builds the polyhedron */
|
||||
void operator()(HDS& hds)
|
||||
|
|
@ -250,9 +247,9 @@ private:
|
|||
Builder B(hds, true);
|
||||
B.begin_surface(m_num_points, m_num_facets);
|
||||
// Add the points:
|
||||
unsigned int counter = 0;
|
||||
Point_adder<HDS, PointIterator_3> add(B);
|
||||
for (PointIterator_3 pi = m_points_begin; pi != m_points_end; ++pi) {
|
||||
size_type counter = 0;
|
||||
Point_adder<HDS, PointIterator> add(B);
|
||||
for (PointIterator pi = m_points_begin; pi != m_points_end; ++pi) {
|
||||
Polyhedron_vertex_handle vh = add(pi);
|
||||
if (counter == m_marked_vertex_index) vh->set_marked(true);
|
||||
++counter;
|
||||
|
|
@ -263,7 +260,7 @@ private:
|
|||
switch (m_num_vertices_per_facet) {
|
||||
case 0: // '0' indicates variant number of vertices per facet
|
||||
{
|
||||
Coord_index_iter ii = m_indices_begin;
|
||||
CoordIndexIter ii = m_indices_begin;
|
||||
while (ii != m_indices_end) {
|
||||
Polyhedron_facet_handle fh = B.begin_facet();
|
||||
if (counter == m_marked_facet_index) fh->set_marked(true);
|
||||
|
|
@ -280,7 +277,7 @@ private:
|
|||
|
||||
case 3:
|
||||
// Unfold for to improve preformance:
|
||||
for (Coord_index_iter ii = m_indices_begin; ii != m_indices_end;
|
||||
for (CoordIndexIter ii = m_indices_begin; ii != m_indices_end;
|
||||
ii += m_num_vertices_per_facet)
|
||||
{
|
||||
Polyhedron_facet_handle fh = B.begin_facet();
|
||||
|
|
@ -294,7 +291,7 @@ private:
|
|||
break;
|
||||
|
||||
default:
|
||||
for (Coord_index_iter ii = m_indices_begin; ii != m_indices_end;
|
||||
for (CoordIndexIter ii = m_indices_begin; ii != m_indices_end;
|
||||
ii += m_num_vertices_per_facet)
|
||||
{
|
||||
Polyhedron_facet_handle fh = B.begin_facet();
|
||||
|
|
@ -314,13 +311,13 @@ private:
|
|||
Visitor* m_visitor;
|
||||
|
||||
/*! The index of the marked vertex */
|
||||
unsigned int m_marked_vertex_index;
|
||||
size_type m_marked_vertex_index;
|
||||
|
||||
/*! The index of the marked edge */
|
||||
unsigned int m_marked_edge_index;
|
||||
size_type m_marked_edge_index;
|
||||
|
||||
/*! The index of the marked face */
|
||||
unsigned int m_marked_facet_index;
|
||||
size_type m_marked_facet_index;
|
||||
|
||||
/*! */
|
||||
Polyhedron_vertex_const_handle m_src_vertex;
|
||||
|
|
@ -356,18 +353,18 @@ private:
|
|||
}
|
||||
|
||||
/*! Update the polyhedron */
|
||||
template <class PointIterator_3>
|
||||
template <typename PointIterator, typename CoordIndexIter>
|
||||
void update_polyhedron(Polyhedron& polyhedron,
|
||||
const PointIterator_3& points_begin,
|
||||
const PointIterator_3& points_end,
|
||||
unsigned int num_points,
|
||||
const Coord_index_iter indices_begin,
|
||||
Coord_index_iter indices_end,
|
||||
unsigned int num_facets,
|
||||
unsigned int num_vertices_per_facet = 0)
|
||||
const PointIterator& points_begin,
|
||||
const PointIterator& points_end,
|
||||
size_type num_points,
|
||||
const CoordIndexIter indices_begin,
|
||||
const CoordIndexIter indices_end,
|
||||
size_type num_facets,
|
||||
size_type num_vertices_per_facet = 0)
|
||||
{
|
||||
/*! The builder */
|
||||
Build_surface<PointIterator_3>
|
||||
Build_surface<PointIterator, CoordIndexIter>
|
||||
surface(points_begin, points_end, num_points,
|
||||
indices_begin, indices_end, num_facets, num_vertices_per_facet);
|
||||
surface.set_marked_vertex_index(m_marked_vertex_index);
|
||||
|
|
@ -376,7 +373,7 @@ private:
|
|||
polyhedron.delegate(surface);
|
||||
|
||||
// Mark the marked (half) edges:
|
||||
unsigned int counter = 0;
|
||||
size_type counter = 0;
|
||||
typedef typename Polyhedron::Edge_iterator Polyhedron_edge_iterator;
|
||||
Polyhedron_edge_iterator ei;
|
||||
for (ei = polyhedron.edges_begin(); ei != polyhedron.edges_end(); ++ei) {
|
||||
|
|
@ -594,14 +591,14 @@ public:
|
|||
}
|
||||
|
||||
/*! Initialize the Spherical Gaussian map */
|
||||
template <class PointIterator_3>
|
||||
void operator()(const PointIterator_3& points_begin,
|
||||
const PointIterator_3& points_end,
|
||||
unsigned int num_points,
|
||||
const Coord_index_iter indices_begin,
|
||||
Coord_index_iter indices_end,
|
||||
unsigned int num_facets,
|
||||
unsigned int num_vertices_per_facet = 0,
|
||||
template <typename PointIterator, typename CoordIndexIter>
|
||||
void operator()(const PointIterator& points_begin,
|
||||
const PointIterator& points_end,
|
||||
size_type num_points,
|
||||
const CoordIndexIter indices_begin,
|
||||
const CoordIndexIter indices_end,
|
||||
size_type num_facets,
|
||||
size_type num_vertices_per_facet = 0,
|
||||
Visitor* visitor = NULL)
|
||||
{
|
||||
m_visitor = visitor;
|
||||
|
|
@ -631,35 +628,37 @@ public:
|
|||
}
|
||||
|
||||
/*! Set the marked-vertex index */
|
||||
void set_marked_vertex_index(unsigned int id) {m_marked_vertex_index = id;}
|
||||
void set_marked_vertex_index(size_type id) {m_marked_vertex_index = id;}
|
||||
|
||||
/*! Set the marked-edge index */
|
||||
void set_marked_edge_index(unsigned int id) {m_marked_edge_index = id;}
|
||||
void set_marked_edge_index(size_type id) {m_marked_edge_index = id;}
|
||||
|
||||
/*! Set the marked-face index */
|
||||
void set_marked_facet_index(unsigned int id) {m_marked_facet_index = id;}
|
||||
void set_marked_facet_index(size_type id) {m_marked_facet_index = id;}
|
||||
};
|
||||
|
||||
/*!
|
||||
*/
|
||||
template <class Geometry_traits_2,
|
||||
template <typename Geometry_traits_2,
|
||||
template <class T>
|
||||
class T_Dcel = Arr_polyhedral_sgm_arr_dcel>
|
||||
class Dcel_T = Arr_polyhedral_sgm_arr_dcel>
|
||||
class Arr_polyhedral_sgm :
|
||||
public Arr_spherical_gaussian_map_3<Geometry_traits_2, T_Dcel>
|
||||
public Arr_spherical_gaussian_map_3<Geometry_traits_2, Dcel_T>
|
||||
{
|
||||
private:
|
||||
typedef Arr_polyhedral_sgm<Geometry_traits_2, T_Dcel> Self;
|
||||
typedef Arr_polyhedral_sgm<Geometry_traits_2, Dcel_T> Self;
|
||||
|
||||
public:
|
||||
typedef typename Geometry_traits_2::Point_3 Point_3;
|
||||
typedef typename Geometry_traits_2::Vector_3 Vector_3;
|
||||
|
||||
typedef T_Dcel<Geometry_traits_2> Dcel;
|
||||
typedef Dcel_T<Geometry_traits_2> Dcel;
|
||||
typedef typename Dcel::Size size_type;
|
||||
|
||||
|
||||
// For some reason MSVC barfs on the friend statement below. Therefore,
|
||||
// we declare the Base to be public to overcome the problem.
|
||||
typedef Arr_spherical_gaussian_map_3<Geometry_traits_2, T_Dcel> Base;
|
||||
typedef Arr_spherical_gaussian_map_3<Geometry_traits_2, Dcel_T> Base;
|
||||
|
||||
// WE NEED TO ADD THE CGAL NAMESPACE TO PACIFY THE G++ 4.3.3 COMPILER.
|
||||
typedef CGAL::Arr_polyhedral_sgm_overlay<Self>
|
||||
|
|
@ -667,7 +666,7 @@ public:
|
|||
|
||||
#if 0
|
||||
/*! Allow the initializer to update the SGM data members */
|
||||
template <class Polyhedron, class Visitor>
|
||||
template <typename Polyhedron, typename Visitor>
|
||||
friend class Arr_polyhedral_sgm_initializer<Self, Polyhedron, Visitor>;
|
||||
#endif
|
||||
|
||||
|
|
@ -701,10 +700,7 @@ public:
|
|||
Arr_polyhedral_sgm() : m_dirty_center(true) {}
|
||||
|
||||
/*! Copy Constructor */
|
||||
Arr_polyhedral_sgm(const Self& sgm)
|
||||
{
|
||||
assign(sgm);
|
||||
}
|
||||
Arr_polyhedral_sgm(const Self& sgm) { assign(sgm); }
|
||||
|
||||
/*! Assign a spherical Gaussian map to this */
|
||||
void assign(const Self& sgm)
|
||||
|
|
@ -750,7 +746,7 @@ public:
|
|||
// /*! Compute the minkowski sum of a range of objects of type
|
||||
// * Arr_polyhedral_sgm
|
||||
// */
|
||||
// template <class SgmIterator>
|
||||
// template <typename SgmIterator>
|
||||
// void minkowski_sum(SgmIterator begin, SgmIterator end)
|
||||
// {
|
||||
//typename SgmIterator::value_type* sgm1 = *begin++;
|
||||
|
|
@ -774,7 +770,7 @@ public:
|
|||
* \param sgm1 the first Arr_polyhedral_sgm object
|
||||
* \param sgm2 the second Arr_polyhedral_sgm object
|
||||
*/
|
||||
template <class Arr_polyhedral_sgm>
|
||||
template <typename Arr_polyhedral_sgm>
|
||||
void minkowski_sum(const Arr_polyhedral_sgm& sgm1,
|
||||
const Arr_polyhedral_sgm& sgm2)
|
||||
{
|
||||
|
|
@ -788,14 +784,14 @@ public:
|
|||
* \param sgm1 the first Arr_polyhedral_sgm object
|
||||
* \param sgm2 the second Arr_polyhedral_sgm object
|
||||
*/
|
||||
template <class Arr_polyhedral_sgm, typename OverlayTraits>
|
||||
template <typename Arr_polyhedral_sgm, typename OverlayTraits>
|
||||
void minkowski_sum(const Arr_polyhedral_sgm& sgm1,
|
||||
const Arr_polyhedral_sgm& sgm2,
|
||||
OverlayTraits& overlay_traits)
|
||||
{ CGAL::overlay(sgm1, sgm2, *this, overlay_traits); }
|
||||
|
||||
/*! Obtain the number of (primal) vertices */
|
||||
unsigned int number_of_vertices() const
|
||||
size_type number_of_vertices() const
|
||||
{ return (static_cast<const Base*>(this))->number_of_faces(); }
|
||||
|
||||
/*! Obtain the number of (primal) edges
|
||||
|
|
@ -804,9 +800,9 @@ public:
|
|||
* been introduced only to make non-x-monotone curves x-monotone.
|
||||
*
|
||||
*/
|
||||
unsigned int number_of_edges() const
|
||||
size_type number_of_edges() const
|
||||
{
|
||||
unsigned int size = 0;
|
||||
size_type size = 0;
|
||||
typename Base::Vertex_const_iterator vit;
|
||||
for (vit = this->vertices_begin(); vit != this->vertices_end(); ++vit)
|
||||
if (vit->degree() == 2) size++;
|
||||
|
|
@ -818,9 +814,9 @@ public:
|
|||
* Vertices of degree 2 are not counted, as they have been introduced only
|
||||
* to make non-x-monotone curves x-monotone.
|
||||
*/
|
||||
unsigned int number_of_facets() const
|
||||
size_type number_of_facets() const
|
||||
{
|
||||
unsigned int size = 0;
|
||||
size_type size = 0;
|
||||
typename Base::Vertex_const_iterator vit;
|
||||
for (vit = this->vertices_begin(); vit != this->vertices_end(); ++vit)
|
||||
if (vit->degree() > 2) size++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue