Commit 918098a5 authored by Pierre Kraemer's avatar Pierre Kraemer

Réécriture de la mise à jour des erreurs par demi-arête après une contraction

parent 0dd92877
......@@ -51,7 +51,7 @@ private:
typename std::multimap<float, Dart>::iterator cur;
void initHalfEdgeInfo(Dart d);
void updateHalfEdgeInfo(Dart d);
void updateHalfEdgeInfo(Dart d, bool recompute);
void computeHalfEdgeInfo(Dart d, HalfEdgeInfo& einfo);
void recomputeQuadric(const Dart d);
......@@ -106,7 +106,7 @@ public:
bool init();
bool nextEdge(Dart& d) const;
void updateBeforeCollapse(Dart d);
void updateAfterCollapse(Dart d2, Dart);
void updateAfterCollapse(Dart d2, Dart dd2);
void updateWithoutCollapse() { }
......@@ -133,65 +133,6 @@ public:
(*errors)[d] = -1;
}
}
class ErrorEvaluator
{
private:
double wA;
double wB;
double wC;
SH* sA;
SH* sB;
SH* sC;
SH* sRef;
VEC3 nA;
VEC3 nB;
VEC3 nC;
VEC3 nRef;
VEC3 cA;
VEC3 cB;
VEC3 cC;
VEC3 cRef;
public:
ErrorEvaluator(
double p_wA,
double p_wB,
double p_wC,
SH* p_sA,
SH* p_sB,
SH* p_sC,
SH* p_sRef,
VEC3 p_nA,
VEC3 p_nB,
VEC3 p_nC,
VEC3 p_nRef,
VEC3 p_cA,
VEC3 p_cB,
VEC3 p_cC,
VEC3 p_cRef
)
{
wA = p_wA; wB = p_wB; wC = p_wC;
sA = p_sA; sB = p_sB; sC = p_sC; sRef = p_sRef;
nA = p_nA; nB = p_nB; nC = p_nC; nRef = p_nRef;
cA = p_cA; cB = p_cB; cC = p_cC; cRef = p_cRef;
}
void set_eval_direction (double x, double y, double z) // fix the direction in which the error has to be evaluated
{
SH::set_eval_direction (x,y,z);
}
double evaluate () // evaluates at a fixed direction
{
VEC3 color_difference ( sRef->evaluate() - wA*sA->evaluate()- wB*sB->evaluate() - wC*sC->evaluate() );
return color_difference.squaredNorm();
}
};
};
} // namespace SCHNApps
......
......@@ -82,28 +82,43 @@ void HalfEdgeSelector_Radiance<PFP>::updateBeforeCollapse(Dart d)
{
MAP& m = this->m_map ;
const Dart& v0 = m.phi1(d) ;
Dart dd = m.phi2(d);
Traversor2VVaE<MAP> tv(m, v0) ;
for (Dart v = tv.begin() ; v != tv.end() ; v = tv.next())
HalfEdgeInfo& edgeE = halfEdgeInfo[d];
if(edgeE.valid)
{
Traversor2VE<MAP> te(m, v) ;
for (Dart he = te.begin() ; he != te.end() ; he = te.next())
{
HalfEdgeInfo* edgeE = &(halfEdgeInfo[he]) ;
if(edgeE->valid)
{
edgeE->valid = false ;
halfEdges.erase(edgeE->it) ;
}
Dart de = m.phi2(he) ;
edgeE = &(halfEdgeInfo[de]) ;
if(edgeE->valid)
{
edgeE->valid = false ;
halfEdges.erase(edgeE->it) ;
}
}
edgeE.valid = false ;
halfEdges.erase(edgeE.it) ;
}
edgeE = halfEdgeInfo[dd];
if(edgeE.valid)
{
edgeE.valid = false ;
halfEdges.erase(edgeE.it) ;
}
edgeE = halfEdgeInfo[m.phi1(d)];
if(edgeE.valid)
{
edgeE.valid = false ;
halfEdges.erase(edgeE.it) ;
}
edgeE = halfEdgeInfo[m.phi_1(d)];
if(edgeE.valid)
{
edgeE.valid = false ;
halfEdges.erase(edgeE.it) ;
}
edgeE = halfEdgeInfo[m.phi1(dd)];
if(edgeE.valid)
{
edgeE.valid = false ;
halfEdges.erase(edgeE.it) ;
}
edgeE = halfEdgeInfo[m.phi_1(dd)];
if(edgeE.valid)
{
edgeE.valid = false ;
halfEdges.erase(edgeE.it) ;
}
}
......@@ -121,28 +136,57 @@ void HalfEdgeSelector_Radiance<PFP>::recomputeQuadric(const Dart d)
}
template <typename PFP>
void HalfEdgeSelector_Radiance<PFP>::updateAfterCollapse(Dart d2, Dart)
void HalfEdgeSelector_Radiance<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
{
MAP& m = this->m_map ;
const Dart& v1 = d2 ;
Dart stop = m.phi2(m.phi_1(d2));
recomputeQuadric(v1) ;
Traversor2VVaE<MAP> tv(m, v1) ;
for (Dart v = tv.begin() ; v != tv.end() ; v = tv.next())
recomputeQuadric(d2);
Dart it = dd2;
do
{
recomputeQuadric(v) ;
}
recomputeQuadric(m.phi1(it));
it = m.phi2(m.phi_1(it));
} while (it != stop);
DartMarkerStore<MAP> dm(m);
Traversor2VVaE<MAP> tv(m, d2);
for (Dart v = tv.begin() ; v != tv.end() ; v = tv.next())
{
Traversor2VE<MAP> te(m,v) ;
for (Dart e = te.begin() ; e != te.end() ; e = te.next())
dm.mark(v);
updateHalfEdgeInfo(v, true);
}
it = dd2;
do
{
Traversor2VVaE<MAP> tv2(m, m.phi1(it));
for (Dart v = tv2.begin() ; v != tv2.end() ; v = tv2.next())
{
updateHalfEdgeInfo(e) ;
updateHalfEdgeInfo(m.phi2(e)) ;
dm.mark(v);
updateHalfEdgeInfo(v, true);
}
it = m.phi2(m.phi_1(it));
} while (it != stop);
Traversor2VE<MAP> te(m, d2);
for (Dart v = te.begin() ; v != te.end() ; v = te.next())
{
if (!dm.isMarked(v))
updateHalfEdgeInfo(v, false);
}
it = dd2;
do
{
Traversor2VE<MAP> te2(m, m.phi1(it));
for (Dart v = te2.begin() ; v != te2.end() ; v = te2.next())
{
if (!dm.isMarked(v))
updateHalfEdgeInfo(v, false);
}
it = m.phi2(m.phi_1(it));
} while (it != stop);
cur = halfEdges.begin() ; // set the current edge to the first one
}
......@@ -161,13 +205,36 @@ void HalfEdgeSelector_Radiance<PFP>::initHalfEdgeInfo(Dart d)
}
template <typename PFP>
void HalfEdgeSelector_Radiance<PFP>::updateHalfEdgeInfo(Dart d)
void HalfEdgeSelector_Radiance<PFP>::updateHalfEdgeInfo(Dart d, bool recompute)
{
MAP& m = this->m_map ;
HalfEdgeInfo& heinfo = halfEdgeInfo[d] ;
if(!heinfo.valid && m.edgeCanCollapse(d))
computeHalfEdgeInfo(d, heinfo) ;
if(recompute)
{
if (heinfo.valid)
halfEdges.erase(heinfo.it);
if (m.edgeCanCollapse(d))
computeHalfEdgeInfo(d, heinfo);
else
heinfo.valid = false;
}
else
{
if (m.edgeCanCollapse(d))
{ // if the edge can be collapsed now
if (!heinfo.valid) // but it was not before
computeHalfEdgeInfo(d, heinfo) ;
}
else
{ // if the edge cannot be collapsed now
if (heinfo.valid) // and it was before
{
halfEdges.erase(heinfo.it) ;
heinfo.valid = false ;
}
}
}
}
template <typename PFP>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment