From: Ian Jackson Date: Mon, 31 Dec 2007 03:30:03 +0000 (+0000) Subject: new edge enumeration arrangements; bugfixes X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius2.git;a=commitdiff_plain;h=83051837693783280938bf36e9e43c7687736753 new edge enumeration arrangements; bugfixes --- diff --git a/bgl.cpp b/bgl.cpp index e75918a..4b06897 100644 --- a/bgl.cpp +++ b/bgl.cpp @@ -44,28 +44,36 @@ extern "C" { */ #define VMASK (YMASK|XMASK) -#define ESHIFT (YBITS|XBITS) +#define ESHIFT (YBITS+XBITS) class Graph { }; // this is a dummy as our graph has no actual representation using namespace boost; /* - * We use the following alternative numbering for iterating over edges: + * We iterate over edges in the following order: * - * ix: \0 /1 - * \ / - * ___ 0 __ - * 2 1 3 - * / \ - * 4/ 5\ + * \#0 /1# + * \ / + * ___ 0 __ + * #2 1 #3 + * / \ + * #4/ #5\ and finally #6 is V6 * * - * This numbering permits the order-4 nodes at the strip's edge - * to have a contiguous edge iterator values 2..5 or 0..3. + * This ordering permits the order-4 nodes at the strip's edge + * to have a contiguous edge iterator values. The iterator + * starts at #0 which is edge 2 (see mgraph.h), or #2 (edge 3). */ -static const int oee_edgemap[V6]= - { 2< { - int v, ix, f; - - void setf() { f= v | oee_edgemap[ix]; } + int f; public: - void increment() { ix++; setf(); } - bool equal(OutEdgeIterator const& other) const { return ix == other.ix; } + void increment() { + //printf("incrementing f=%03x..",f); + f += oei_edge_delta[f>>ESHIFT]; + //printf("%03x\n",f); + } + bool equal(OutEdgeIterator const& other) const { return f == other.f; } int const& dereference() const { return f; } OutEdgeIterator() { } - OutEdgeIterator(int _v, int _ix) : v(_v), ix(_ix) { setf(); } + OutEdgeIterator(int _f) : f(_f) { } + OutEdgeIterator(int v, int e) : f(e< VertexIterator; @@ -129,7 +143,7 @@ namespace boost { OutEdgeIterator(v, OutEdgeIterator::voe_max(v))); } inline unsigned out_degree(int v, const Graph&) { - return OutEdgeIterator::voe_max(v) - OutEdgeIterator::voe_min(v); + return OutEdgeIterator::voe_degree(v); } // Concept VertexListGraph: diff --git a/energy.c b/energy.c index b2ee073..89b56e2 100644 --- a/energy.c +++ b/energy.c @@ -247,8 +247,8 @@ static double edgewise_vertex_displacement_cost(const Vertices vertices) { FOR_EDGE(pi,e,qi) { ri= EDGE_END2(pi,(e+1)%V6); if (ri<0) continue; si= EDGE_END2(pi,(e+5)%V6); if (si<0) continue; - assert(ri == EDGE_END2(qi,(e+2)%V6)); - assert(si == EDGE_END2(qi,(e+4)%V6)); + /* assert(ri == EDGE_END2(qi,(e+2)%V6)); */ + /* assert(si == EDGE_END2(qi,(e+4)%V6)); */ K m[k]= (vertices[pi][k] + vertices[qi][k]) * 0.5; K mprime[k]= (vertices[ri][k] + vertices[si][k]) * 0.5;