Static method Insert added, to avoid some code repetition.
This commit is contained in:
parent
f93ee8b17d
commit
108af1cd44
vcg/complex/local_optimization
|
@ -85,6 +85,15 @@ protected:
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Insert(HeapType& heap, PosType& p, int mark)
|
||||||
|
{
|
||||||
|
if(!p.IsBorder() && p.F()->IsW() && p.FFlip()->IsW()) {
|
||||||
|
MYTYPE* newflip = new MYTYPE(p, mark);
|
||||||
|
heap.push_back(HeapElem(newflip));
|
||||||
|
std::push_heap(heap.begin(), heap.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Default constructor
|
* Default constructor
|
||||||
|
@ -287,8 +296,11 @@ public:
|
||||||
if(!(*fi).IsD() && (*fi).IsW()) {
|
if(!(*fi).IsD() && (*fi).IsW()) {
|
||||||
for(unsigned int i = 0; i < 3; i++) {
|
for(unsigned int i = 0; i < 3; i++) {
|
||||||
if( !(*fi).IsB(i) && !((*fi).FFp(i)->IsD()) && (*fi).FFp(i)->IsW() ) {
|
if( !(*fi).IsB(i) && !((*fi).FFp(i)->IsD()) && (*fi).FFp(i)->IsW() ) {
|
||||||
if((*fi).V1(i) - (*fi).V0(i) > 0)
|
if((*fi).V1(i) - (*fi).V0(i) > 0) {
|
||||||
heap.push_back( HeapElem( new MYTYPE(PosType(&*fi, i), mesh.IMark() )) );
|
PosType p(&*fi, i);
|
||||||
|
Insert(heap, p, mesh.IMark());
|
||||||
|
}
|
||||||
|
//heap.push_back( HeapElem( new MYTYPE(PosType(&*fi, i), mesh.IMark() )) );
|
||||||
} //endif
|
} //endif
|
||||||
} //endfor
|
} //endfor
|
||||||
}
|
}
|
||||||
|
@ -312,29 +324,17 @@ public:
|
||||||
pos.F()->FFp(flipped)->V2(pos.F()->FFi(flipped))->IMark() = GlobalMark();
|
pos.F()->FFp(flipped)->V2(pos.F()->FFi(flipped))->IMark() = GlobalMark();
|
||||||
|
|
||||||
pos.FlipF(); pos.FlipE();
|
pos.FlipF(); pos.FlipE();
|
||||||
if(!pos.IsBorder() && pos.FFlip()->IsW()) {
|
Insert(heap, pos, GlobalMark());
|
||||||
heap.push_back(HeapElem(new MYTYPE(pos, GlobalMark())));
|
|
||||||
std::push_heap(heap.begin(), heap.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
pos.FlipV(); pos.FlipE();
|
pos.FlipV(); pos.FlipE();
|
||||||
if(!pos.IsBorder() && pos.FFlip()->IsW()) {
|
Insert(heap, pos, GlobalMark());
|
||||||
heap.push_back(HeapElem(new MYTYPE(pos, GlobalMark())));
|
|
||||||
std::push_heap(heap.begin(), heap.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
pos.FlipV(); pos.FlipE();
|
pos.FlipV(); pos.FlipE();
|
||||||
pos.FlipF(); pos.FlipE();
|
pos.FlipF(); pos.FlipE();
|
||||||
if(!pos.IsBorder() && pos.FFlip()->IsW()) {
|
Insert(heap, pos, GlobalMark());
|
||||||
heap.push_back(HeapElem(new MYTYPE(pos, GlobalMark())));
|
|
||||||
std::push_heap(heap.begin(), heap.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
pos.FlipV(); pos.FlipE();
|
pos.FlipV(); pos.FlipE();
|
||||||
if(!pos.IsBorder() && pos.FFlip()->IsW()) {
|
Insert(heap, pos, GlobalMark());
|
||||||
heap.push_back(HeapElem(new MYTYPE(pos, GlobalMark())));
|
|
||||||
std::push_heap(heap.begin(), heap.end());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}; // end of PlanarEdgeFlip class
|
}; // end of PlanarEdgeFlip class
|
||||||
|
|
||||||
|
@ -556,19 +556,13 @@ public:
|
||||||
// edges of the first face, except the flipped edge
|
// edges of the first face, except the flipped edge
|
||||||
for(int i = 0; i < 3; i++) if(i != flipped) {
|
for(int i = 0; i < 3; i++) if(i != flipped) {
|
||||||
PosType newpos(f1, i);
|
PosType newpos(f1, i);
|
||||||
if(!newpos.IsBorder() && f1->FFp(i)->IsW()) {
|
Insert(heap, newpos, this->GlobalMark());
|
||||||
heap.push_back(HeapElem(new MYTYPE(newpos, this->GlobalMark())));
|
|
||||||
std::push_heap(heap.begin(), heap.end());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// edges of the second face, except the flipped edge
|
// edges of the second face, except the flipped edge
|
||||||
for(int i = 0; i < 3; i++) if(i != f1->FFi(flipped)) {
|
for(int i = 0; i < 3; i++) if(i != f1->FFi(flipped)) {
|
||||||
PosType newpos(f2, i);
|
PosType newpos(f2, i);
|
||||||
if(!newpos.IsBorder() && f2->FFp(i)->IsW()) {
|
Insert(heap, newpos, this->GlobalMark());
|
||||||
heap.push_back(HeapElem(new MYTYPE(newpos, this->GlobalMark())));
|
|
||||||
std::push_heap(heap.begin(), heap.end());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// every edge with v0, v1 v3 of f1
|
// every edge with v0, v1 v3 of f1
|
||||||
|
@ -578,33 +572,31 @@ public:
|
||||||
|
|
||||||
do { // go to the first border (if there is one)
|
do { // go to the first border (if there is one)
|
||||||
pos.NextE();
|
pos.NextE();
|
||||||
}while(pos != startpos && !pos.IsBorder());
|
} while(pos != startpos && !pos.IsBorder());
|
||||||
|
|
||||||
do {
|
do {
|
||||||
VertexPointer v = pos.VFlip();
|
VertexPointer v = pos.VFlip();
|
||||||
if(v != v0 && v != v1 && v != v2 && v != v3 && pos.F()->FFp(pos.E())->IsW()) {
|
if(v != v0 && v != v1 && v != v2 && v != v3)
|
||||||
heap.push_back(HeapElem(new MYTYPE(pos, this->GlobalMark())));
|
Insert(heap, pos, this->GlobalMark());
|
||||||
std::push_heap(heap.begin(), heap.end());
|
|
||||||
}
|
|
||||||
pos.NextE();
|
pos.NextE();
|
||||||
}while(pos != startpos && !pos.IsBorder());
|
} while(pos != startpos && !pos.IsBorder());
|
||||||
}
|
}
|
||||||
|
|
||||||
PosType startpos(f2, f1->FFi(flipped));
|
PosType startpos(f2, (f1->FFi(flipped) + 2) % 3);
|
||||||
PosType pos(startpos);
|
PosType pos(startpos);
|
||||||
|
|
||||||
do { // go to the first border (if there is one)
|
do { // go to the first border (if there is one)
|
||||||
pos.NextE();
|
pos.NextE();
|
||||||
}while(pos != pos && !pos.IsBorder());
|
} while(pos != startpos && !pos.IsBorder());
|
||||||
|
|
||||||
do {
|
do {
|
||||||
VertexPointer v = pos.VFlip();
|
VertexPointer v = pos.VFlip();
|
||||||
if(v != v0 && v != v1 && v != v2 && v != v3 && pos.F()->FFp(pos.E())->IsW()) {
|
if(v != v0 && v != v1 && v != v2 && v != v3)
|
||||||
heap.push_back(HeapElem(new MYTYPE(pos, this->GlobalMark())));
|
Insert(heap, pos, this->GlobalMark());
|
||||||
std::push_heap(heap.begin(), heap.end());
|
|
||||||
}
|
|
||||||
pos.NextE();
|
pos.NextE();
|
||||||
}while(pos != startpos && !pos.IsBorder());
|
} while(pos != startpos && !pos.IsBorder());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue