removed a useless loop in the update cycle of the heap of the edges to be collapesed. Stupid bug pointed out by Enrico (thanks!)
This commit is contained in:
parent
794f2f27a7
commit
2b9a9f2be2
vcg/complex/algorithms/local_optimization
|
@ -134,61 +134,56 @@ public:
|
||||||
|
|
||||||
inline void UpdateHeap(HeapType & h_ret, BaseParameterClass *pp)
|
inline void UpdateHeap(HeapType & h_ret, BaseParameterClass *pp)
|
||||||
{
|
{
|
||||||
GlobalMark()++; int nn=0;
|
GlobalMark()++;
|
||||||
VertexType *v[2];
|
VertexType *v[2];
|
||||||
v[0]= pos.V(0);v[1]=pos.V(1);
|
v[0]= pos.V(0);v[1]=pos.V(1);
|
||||||
v[1]->IMark() = GlobalMark();
|
v[1]->IMark() = GlobalMark();
|
||||||
|
|
||||||
// First loop around the remaining vertex to unmark visited flags
|
// First loop around the remaining vertex to unmark visited flags
|
||||||
vcg::face::VFIterator<FaceType> vfi(v[1]);
|
vcg::face::VFIterator<FaceType> vfi(v[1]);
|
||||||
while (!vfi.End()){
|
while (!vfi.End()){
|
||||||
vfi.V1()->ClearV();
|
vfi.V1()->ClearV();
|
||||||
vfi.V2()->ClearV();
|
vfi.V2()->ClearV();
|
||||||
++vfi;
|
++vfi;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second Loop: add all the outgoing edges around v[1]
|
// Second Loop: add all the outgoing edges around v[1]
|
||||||
// for each face add the two edges outgoing from v[1] and not visited.
|
// for each face add the two edges outgoing from v[1] and not visited.
|
||||||
vfi = face::VFIterator<FaceType>(v[1]);
|
vfi = face::VFIterator<FaceType>(v[1]);
|
||||||
while (!vfi.End())
|
while (!vfi.End())
|
||||||
{
|
{
|
||||||
assert(!vfi.F()->IsD());
|
assert(!vfi.F()->IsD());
|
||||||
for (int j=0;j<3;j++)
|
if( !(vfi.V1()->IsV()) && (vfi.V1()->IsRW()))
|
||||||
{
|
{
|
||||||
if( !(vfi.V1()->IsV()) && (vfi.V1()->IsRW()))
|
vfi.V1()->SetV();
|
||||||
{
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair( vfi.V(),vfi.V1() ),GlobalMark(),pp)));
|
||||||
vfi.V1()->SetV();
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair( vfi.V(),vfi.V1() ),GlobalMark(),pp)));
|
if(! this->IsSymmetric(pp)){
|
||||||
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair( vfi.V1(),vfi.V()),GlobalMark(),pp)));
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
if(! this->IsSymmetric(pp)){
|
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair( vfi.V1(),vfi.V()),GlobalMark(),pp)));
|
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if( !(vfi.V2()->IsV()) && (vfi.V2()->IsRW()))
|
}
|
||||||
{
|
if( !(vfi.V2()->IsV()) && (vfi.V2()->IsRW()))
|
||||||
vfi.V2()->SetV();
|
{
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.F()->V(vfi.I()),vfi.F()->V2(vfi.I())),GlobalMark(),pp)));
|
vfi.V2()->SetV();
|
||||||
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.F()->V(vfi.I()),vfi.F()->V2(vfi.I())),GlobalMark(),pp)));
|
||||||
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
|
if(! this->IsSymmetric(pp)){
|
||||||
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair (vfi.F()->V1(vfi.I()),vfi.F()->V(vfi.I())),GlobalMark(),pp)));
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
if(! this->IsSymmetric(pp)){
|
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair (vfi.F()->V1(vfi.I()),vfi.F()->V(vfi.I())),GlobalMark(),pp)));
|
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// if(vfi.V1()->IsRW() && vfi.V2()->IsRW() )
|
}
|
||||||
// {
|
// if(vfi.V1()->IsRW() && vfi.V2()->IsRW() )
|
||||||
// h_ret.push_back(HeapElem(new MYTYPE(EdgeType(vfi.V1(),vfi.V2()),this->GlobalMark())));
|
// {
|
||||||
// std::push_heap(h_ret.begin(),h_ret.end());
|
// h_ret.push_back(HeapElem(new MYTYPE(EdgeType(vfi.V1(),vfi.V2()),this->GlobalMark())));
|
||||||
// if(IsSymmetric()){
|
// std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
// h_ret.push_back(HeapElem(new MYTYPE(EdgeType(vfi.V2(),vfi.V1()), this->GlobalMark())));
|
// if(IsSymmetric()){
|
||||||
// std::push_heap(h_ret.begin(),h_ret.end());
|
// h_ret.push_back(HeapElem(new MYTYPE(EdgeType(vfi.V2(),vfi.V1()), this->GlobalMark())));
|
||||||
// }
|
// std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
// }
|
// }
|
||||||
|
// }
|
||||||
}
|
++vfi;
|
||||||
++vfi;nn++;
|
} // end while
|
||||||
}
|
|
||||||
// printf("ADDED %d\n",nn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModifierType IsOfType(){ return TriEdgeCollapseOp;}
|
ModifierType IsOfType(){ return TriEdgeCollapseOp;}
|
||||||
|
|
|
@ -453,63 +453,61 @@ public:
|
||||||
inline void UpdateHeap(HeapType & h_ret,BaseParameterClass *_pp)
|
inline void UpdateHeap(HeapType & h_ret,BaseParameterClass *_pp)
|
||||||
{
|
{
|
||||||
QParameter *pp=(QParameter *)_pp;
|
QParameter *pp=(QParameter *)_pp;
|
||||||
this->GlobalMark()++;
|
this->GlobalMark()++;
|
||||||
VertexType *v[2];
|
VertexType *v[2];
|
||||||
v[0]= this->pos.V(0);
|
v[0]= this->pos.V(0);
|
||||||
v[1]= this->pos.V(1);
|
v[1]= this->pos.V(1);
|
||||||
v[1]->IMark() = this->GlobalMark();
|
v[1]->IMark() = this->GlobalMark();
|
||||||
|
|
||||||
// First loop around the remaining vertex to unmark visited flags
|
// First loop around the remaining vertex to unmark visited flags
|
||||||
vcg::face::VFIterator<FaceType> vfi(v[1]);
|
vcg::face::VFIterator<FaceType> vfi(v[1]);
|
||||||
while (!vfi.End()){
|
while (!vfi.End()){
|
||||||
vfi.V1()->ClearV();
|
vfi.V1()->ClearV();
|
||||||
vfi.V2()->ClearV();
|
vfi.V2()->ClearV();
|
||||||
++vfi;
|
++vfi;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second Loop
|
// Second Loop
|
||||||
vfi = face::VFIterator<FaceType>(v[1]);
|
vfi = face::VFIterator<FaceType>(v[1]);
|
||||||
while (!vfi.End())
|
while (!vfi.End())
|
||||||
{
|
{
|
||||||
assert(!vfi.F()->IsD());
|
assert(!vfi.F()->IsD());
|
||||||
for (int j=0;j<3;j++)
|
if( !(vfi.V1()->IsV()) && vfi.V1()->IsRW())
|
||||||
{
|
{
|
||||||
if( !(vfi.V1()->IsV()) && vfi.V1()->IsRW())
|
vfi.V1()->SetV();
|
||||||
{
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V0(),vfi.V1()), this->GlobalMark(),_pp)));
|
||||||
vfi.V1()->SetV();
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V0(),vfi.V1()), this->GlobalMark(),_pp)));
|
if(!IsSymmetric(pp)){
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V1(),vfi.V0()), this->GlobalMark(),_pp)));
|
||||||
if(!IsSymmetric(pp)){
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V1(),vfi.V0()), this->GlobalMark(),_pp)));
|
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if( !(vfi.V2()->IsV()) && vfi.V2()->IsRW())
|
}
|
||||||
{
|
if( !(vfi.V2()->IsV()) && vfi.V2()->IsRW())
|
||||||
vfi.V2()->SetV();
|
{
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V0(),vfi.V2()),this->GlobalMark(),_pp)));
|
vfi.V2()->SetV();
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V0(),vfi.V2()),this->GlobalMark(),_pp)));
|
||||||
if(!IsSymmetric(pp)){
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
h_ret.push_back( HeapElem(new MYTYPE(VertexPair(vfi.V2(),vfi.V0()), this->GlobalMark(),_pp) ) );
|
if(!IsSymmetric(pp)){
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
h_ret.push_back( HeapElem(new MYTYPE(VertexPair(vfi.V2(),vfi.V0()), this->GlobalMark(),_pp) ) );
|
||||||
}
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
}
|
}
|
||||||
if(pp->SafeHeapUpdate && vfi.V1()->IsRW() && vfi.V2()->IsRW() )
|
}
|
||||||
{
|
if(pp->SafeHeapUpdate && vfi.V1()->IsRW() && vfi.V2()->IsRW() )
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V1(),vfi.V2()),this->GlobalMark(),_pp)));
|
{
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V1(),vfi.V2()),this->GlobalMark(),_pp)));
|
||||||
if(!IsSymmetric(pp)){
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V2(),vfi.V1()), this->GlobalMark(),_pp)));
|
if(!IsSymmetric(pp)){
|
||||||
std::push_heap(h_ret.begin(),h_ret.end());
|
h_ret.push_back(HeapElem(new MYTYPE(VertexPair(vfi.V2(),vfi.V1()), this->GlobalMark(),_pp)));
|
||||||
}
|
std::push_heap(h_ret.begin(),h_ret.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++vfi;
|
++vfi;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitQuadric(TriMeshType &m,BaseParameterClass *_pp)
|
static void InitQuadric(TriMeshType &m,BaseParameterClass *_pp)
|
||||||
{
|
{
|
||||||
QParameter *pp=(QParameter *)_pp;
|
QParameter *pp=(QParameter *)_pp;
|
||||||
typename TriMeshType::FaceIterator pf;
|
typename TriMeshType::FaceIterator pf;
|
||||||
|
|
Loading…
Reference in New Issue