Rev 519 | Rev 585 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/* ----------------------------------------------------------------------- *
* This file is part of GEL, www.imm.dtu.dk/GEL
* Copyright (C) the authors (see AUTHORS.txt) and DTU Informatics
*
* Principal authors:
* Christian Thode Larsen (thode2d@gmail.com)
* J. Andreas Baerentzen (jab@imm.dtu.dk)
*
* See LICENSE.txt for licensing information
* ----------------------------------------------------------------------- */
#include "refine_edges.h"
#include <vector>
#include <iterator>
#include "Manifold.h"
#include "AttributeVector.h"
namespace HMesh
{
using namespace std;
float average_edge_length(const Manifold& m)
{
float lsum = 0;
for(HalfEdgeIDIterator h = m.halfedges_begin(); h != m.halfedges_end(); ++h)
lsum += length(m, *h);
return lsum / m.active_halfedges();
}
int refine_edges(Manifold& m, float t)
{
int work = 0;
vector<HalfEdgeID> hedges;
hedges.reserve(m.active_halfedges());
copy(m.halfedges_begin(), m.halfedges_end(), back_inserter(hedges));
HalfEdgeAttributeVector<int> touched(m.total_halfedges(), 0);
cout << "Refining edges";
for(vector<HalfEdgeID>::iterator h = hedges.begin(); h != hedges.end(); ++h){
HalfEdgeWalker w = m.halfedgewalker(*h);
if(!m.in_use(*h) || w.face() == InvalidFaceID || length(m, *h) < t || touched[*h])
continue;
++work;
if( work % 10000 == 0)
cout << ".";
touched[w.opp().halfedge()] = 1;
VertexID v = m.split_edge(*h);
HalfEdgeWalker wv = m.halfedgewalker(v);
FaceID f1 = wv.opp().face();
// if(f1 != InvalidFaceID)
// m.split_face_by_vertex(f1);
FaceID f2 = wv.prev().face();
// if(f2 != InvalidFaceID)
// m.split_face_by_vertex(f2);
}
cout << endl;
return work;
}
}