mirror of https://github.com/CGAL/cgal
Improve the face end for non convex face to allow to draw faces with holes.
This commit is contained in:
parent
eb6354425f
commit
fc6e3c6a5a
|
|
@ -35,7 +35,7 @@
|
|||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <queue>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <map>
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
|
@ -606,8 +606,23 @@ protected:
|
|||
{
|
||||
P_traits cdt_traits(normal);
|
||||
CDT cdt(cdt_traits);
|
||||
|
||||
bool with_vertex_normal=(m_vertex_normals_for_face.size()==m_points_of_face.size());
|
||||
Local_point p1, p2;
|
||||
|
||||
// For each point of the face, store the list of adjacent points and the number of time
|
||||
// the edge is found in the face. For an edge p1, p2, store edge min(p1,p2)->max(p1,p2)
|
||||
std::map<Local_point, std::map<Local_point, unsigned int> > edges;
|
||||
for (unsigned int i=0; i<m_points_of_face.size(); ++i)
|
||||
{
|
||||
p1=m_points_of_face[i];
|
||||
p2=m_points_of_face[i==0?m_points_of_face.size()-1:i-1];
|
||||
if (p2<p1) { std::swap(p1, p2); }
|
||||
|
||||
if (edges.count(p1)==0)
|
||||
{ std::map<Local_point, unsigned int> m; m[p2]=1; edges[p1]=m; }
|
||||
else if (edges[p1].count(p2)==0) { edges[p1][p2]=1; }
|
||||
else { ++(edges[p1][p2]); }
|
||||
}
|
||||
|
||||
// (1) We insert all the edges as contraint in the CDT.
|
||||
typename CDT::Vertex_handle previous=NULL, first=NULL;
|
||||
|
|
@ -626,12 +641,22 @@ protected:
|
|||
{ vh->info().index=m_indices_of_points_of_face[i]; }
|
||||
|
||||
if(previous!=NULL && previous!=vh)
|
||||
{ cdt.insert_constraint(previous, vh); }
|
||||
{
|
||||
p1=m_points_of_face[i]; p2=m_points_of_face[i-1];
|
||||
if (p2<p1) { std::swap(p1, p2); }
|
||||
if ((edges[p1][p2])%2==1) // odd number of time => constraint
|
||||
{ cdt.insert_constraint(previous, vh); }
|
||||
}
|
||||
previous=vh;
|
||||
}
|
||||
|
||||
if (previous!=NULL && previous!=first)
|
||||
{ cdt.insert_constraint(previous, first); }
|
||||
{
|
||||
p1=m_points_of_face[m_points_of_face.size()-1]; p2=m_points_of_face[0];
|
||||
if (p2<p1) std::swap(p1, p2);
|
||||
if ((edges[p1][p2])%2==1) // odd number of time => constraint
|
||||
{ cdt.insert_constraint(previous, first); }
|
||||
}
|
||||
|
||||
// (2) We mark all external triangles
|
||||
// (2.1) We initialize is_external and is_process values
|
||||
|
|
|
|||
Loading…
Reference in New Issue