Subversion Repositories gelsvn

Rev

Rev 182 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
595 jab 1
/* ----------------------------------------------------------------------- *
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 * Copyright (C) the authors and DTU Informatics
4
 * For license and list of authors, see ../../doc/intro.pdf
5
 * ----------------------------------------------------------------------- */
149 jab 6
 
7
#include "refine_edges.h"
8
 
595 jab 9
#include <vector>
10
#include <iterator>
149 jab 11
 
595 jab 12
#include "Manifold.h"
13
#include "AttributeVector.h"
14
 
150 jab 15
namespace HMesh
149 jab 16
{
595 jab 17
    using namespace std;
149 jab 18
 
595 jab 19
    float average_edge_length(const Manifold& m)
20
    {
21
        float lsum = 0;
22
        for(HalfEdgeIDIterator h = m.halfedges_begin(); h != m.halfedges_end(); ++h)
23
            lsum += length(m, *h);
24
        return lsum / m.no_halfedges();
25
    }
149 jab 26
 
595 jab 27
    int refine_edges(Manifold& m, float t)
28
    {
29
        int work = 0;
30
 
31
        vector<HalfEdgeID> hedges;
32
        hedges.reserve(m.no_halfedges());
33
        copy(m.halfedges_begin(), m.halfedges_end(), back_inserter(hedges));
149 jab 34
 
595 jab 35
        HalfEdgeAttributeVector<int> touched(m.allocated_halfedges(), 0);
149 jab 36
 
595 jab 37
        cout << "Refining edges";
38
        for(vector<HalfEdgeID>::iterator h = hedges.begin(); h != hedges.end(); ++h){
39
            Walker w = m.walker(*h);
149 jab 40
 
595 jab 41
            if(!m.in_use(*h) || w.face() == InvalidFaceID || length(m, *h) < t || touched[*h])
42
                continue;
149 jab 43
 
595 jab 44
            ++work;
45
            if( work % 10000 == 0)
46
                cout << ".";
149 jab 47
 
595 jab 48
            touched[w.opp().halfedge()] = 1;
49
//            VertexID v = m.split_edge(*h);
50
 
51
//            Walker wv = m.walker(v);
52
 
53
//            FaceID f1 = wv.opp().face();
54
           // if(f1 != InvalidFaceID)
55
             //   m.split_face_by_vertex(f1);
56
 
57
//            FaceID f2 =  wv.prev().face();
58
           // if(f2 != InvalidFaceID)
59
            //    m.split_face_by_vertex(f2);
60
 
61
        }
62
        cout << endl;
63
        return work;
64
    }
65
 
149 jab 66
}