remove halfedge_collapse_Polyhedron_3.h

This commit is contained in:
Andreas Fabri 2014-05-28 12:13:48 +02:00
parent ae75e031c8
commit 0e02466b2b
1 changed files with 0 additions and 184 deletions

View File

@ -1,184 +0,0 @@
// Copyright (c) 2006 GeometryFactory (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// 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) : Fernando Cacciola <fernando.cacciola@geometryfactory.com>
//
#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_COLLAPSE_TRIANGULATION_EDGE_POLYHEDRON_3_H
#define CGAL_SURFACE_MESH_SIMPLIFICATION_COLLAPSE_TRIANGULATION_EDGE_POLYHEDRON_3_H
#include <CGAL/Surface_mesh_simplification/Detail/Common.h>
#include <CGAL/Polyhedron_3.h>
# define CGAL_HDS_PARAM_ template < class Traits, class Items, class Alloc> class HDS
namespace CGAL {
namespace Surface_mesh_simplification
{
/*
Function responsible for contracting an edge while respecting constrained edges
Notations used in the following function:
Top=TopFace
Btm=BottomFace
t
/ \
/ \
/ Top \
p -------- q
\ Btm /
\ /
\ /
b
Prerequisites:
If Top exists, amongst p-t and t-q only one is constrained
If Btm exists, amongst p-b and q-b only one is constrained
p-q is not constrained
*/
template<class Gt, class I, CGAL_HDS_PARAM_, class A, class EdgeIsConstrainedMap>
typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor
halfedge_collapse( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::halfedge_descriptor const& pq
, Polyhedron_3<Gt,I,HDS,A>& aSurface
, EdgeIsConstrainedMap Edge_is_constrained_map
)
{
CGAL_assertion( !get(Edge_is_constrained_map,pq) );
typedef Polyhedron_3<Gt,I,HDS,A> Surface ;
typedef typename boost::graph_traits<Surface>::vertex_descriptor vertex_descriptor ;
typedef typename boost::graph_traits<Surface>::halfedge_descriptor halfedge_descriptor ;
halfedge_descriptor qp = opposite(pq,aSurface);
halfedge_descriptor pt = opposite(prev(pq,aSurface),aSurface);
halfedge_descriptor qb = opposite(prev(qp,aSurface),aSurface);
halfedge_descriptor tq = opposite(next(pq,aSurface),aSurface);
halfedge_descriptor bp = opposite(next(qp,aSurface),aSurface);
bool lTopFaceExists = !pq->is_border() ;
bool lBottomFaceExists = !qp->is_border() ;
vertex_descriptor q = target(pq,aSurface);
vertex_descriptor p = source(pq,aSurface);
//used to collect edges to remove from the surface
halfedge_descriptor edges_to_erase[2];
halfedge_descriptor* edges_to_erase_ptr=edges_to_erase;
// If the top facet exists, we need to choose one out of the two edges which one disappears:
// p-t if it is not constrained and t-q otherwise
if ( lTopFaceExists )
{
if ( !get(Edge_is_constrained_map,pt) )
{
*edges_to_erase_ptr++=pt;
}
else
{
*edges_to_erase_ptr++=tq;
}
}
// If the bottom facet exists, we need to choose one out of the two edges which one disappears:
// q-b if it is not constrained and b-p otherwise
if ( lBottomFaceExists )
{
if ( !get(Edge_is_constrained_map,qb) )
{
*edges_to_erase_ptr++=qb;
}
else{
*edges_to_erase_ptr++=bp;
}
}
if (lTopFaceExists && lBottomFaceExists)
{
if ( edges_to_erase[0]->facet()==edges_to_erase[1]->facet()
&& !edges_to_erase[0]->is_border() )
{
// the vertex is of valence 3 and we simply need to remove the vertex
// and its indicent edges
bool lP_Erased=false;
halfedge_descriptor edge =
edges_to_erase[0]->next()==edges_to_erase[1]?
edges_to_erase[0]:edges_to_erase[1];
if (edge->vertex()==p)
lP_Erased=true;
aSurface.erase_center_vertex(edge);
return lP_Erased? q : p;
}
else
{
if (!edges_to_erase[0]->is_border())
aSurface.join_facet(edges_to_erase[0]);
else
aSurface.erase_facet(edges_to_erase[0]->opposite());
if (!edges_to_erase[1]->is_border())
aSurface.join_facet(edges_to_erase[1]);
else
aSurface.erase_facet(edges_to_erase[1]->opposite());
aSurface.join_vertex(pq);
return q;
}
}
else
{
if (lTopFaceExists)
{
if (!edges_to_erase[0]->is_border()){
aSurface.join_facet(edges_to_erase[0]);
aSurface.join_vertex(pq);
return q;
}
bool lQ_Erased=pq->next()->opposite()->is_border();
aSurface.erase_facet(edges_to_erase[0]->opposite());
return lQ_Erased?p:q;
}
if (!edges_to_erase[0]->is_border()){
aSurface.join_facet(edges_to_erase[0]);
aSurface.join_vertex(qp);
return p;
}
bool lP_Erased=qp->next()->opposite()->is_border();
aSurface.erase_facet(edges_to_erase[0]->opposite());
return lP_Erased?q:p;
};
}
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor
halfedge_collapse( typename boost::graph_traits< Polyhedron_3<Gt,I,HDS,A> >::halfedge_descriptor const& pq
, Polyhedron_3<Gt,I,HDS,A>& aSurface
)
{
return halfedge_collapse( pq,
aSurface,
No_constrained_edge_map<Polyhedron_3<Gt,I,HDS,A> >() );
}
} // namespace Surface_mesh_simplification
} //namespace CGAL
#undef CGAL_HDS_PARAM
#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_COLLAPSE_TRIANGULATION_EDGE_POLYHEDRON_3_H
// EOF //