Commit d6a8ae63 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

some phi2->phi1 conversions + correction of memory failure in exportPlyPTM

parent 6bba6520
......@@ -94,9 +94,7 @@ public:
typedef typename PFP::REAL REAL ;
typedef Geom::Matrix<3,3,REAL> MATRIX33 ;
typedef MATRIX33 FRAME ;
typedef Geom::Matrix<3,6,REAL> MATRIX36 ;
typedef MATRIX36 RGBFUNCTIONS ;
private:
typedef struct
......@@ -107,7 +105,7 @@ private:
} LightfieldHalfEdgeInfo ;
typedef NoMathIOAttribute<LightfieldHalfEdgeInfo> HalfEdgeInfo ;
AttributeHandler<FRAME > m_frame ;
AttributeHandler<MATRIX33 > m_frame ;
AttributeHandler<HalfEdgeInfo> halfEdgeInfo ;
AttributeHandler<Quadric<REAL> > quadric ;
......@@ -117,8 +115,8 @@ private:
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, VEC3>* m_positionApproximator ;
Approximator<PFP, FRAME >* m_frameApproximator ;
Approximator<PFP, RGBFUNCTIONS >* m_RGBfunctionsApproximator ;
Approximator<PFP, MATRIX33 >* m_frameApproximator ;
Approximator<PFP, MATRIX36 >* m_RGBfunctionsApproximator ;
void initHalfEdgeInfo(Dart d) ;
void updateHalfEdgeInfo(Dart d, bool recompute) ;
......@@ -129,7 +127,7 @@ public:
HalfEdgeSelector_Lightfield(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
m_frame = m.template getAttribute<FRAME>(VERTEX_ORBIT, "frame") ;
m_frame = m.template getAttribute<MATRIX33>(VERTEX_ORBIT, "frame") ;
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo>(DART_ORBIT, "halfEdgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL> >(VERTEX_ORBIT, "QEMquadric") ;
......
......@@ -125,6 +125,7 @@ void HalfEdgeSelector_QEMml<PFP>::updateBeforeCollapse(Dart d)
halfEdges.erase(edgeE.it) ;
// from the multimap
Dart dd = m.phi2(d) ;
assert(dd != d) ;
if(dd != d)
{
edgeE = halfEdgeInfo[dd] ;
......@@ -162,9 +163,10 @@ void HalfEdgeSelector_QEMml<PFP>::recomputeQuadric(const Dart d, const bool reco
dBack = this->m_map.phi1(dFront) ;
dFront = this->m_map.alpha1(dFront) ;
if (dBack != dFront) { // if dFront is no border
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi1(dFront)],this->m_position[dBack]) ;
if (this->m_map.phi2(dFront) != dFront) { // if dFront is no border
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[dBack],this->m_position[this->m_map.phi1(dFront)]) ;
}
if (recomputeNeighbors)
recomputeQuadric(dBack, false) ;
......@@ -182,19 +184,30 @@ void HalfEdgeSelector_QEMml<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
do
{
updateHalfEdgeInfo(vit, true) ;
updateHalfEdgeInfo(m.phi2(vit), true) ;
Dart d = m.phi2(vit) ;
if (d != vit) ;
updateHalfEdgeInfo(d, true) ;
updateHalfEdgeInfo(m.phi1(vit), true) ;
updateHalfEdgeInfo(m.phi2(m.phi1(vit)), true) ;
d = m.phi2(m.phi1(vit)) ;
if (d != m.phi1(vit)) ;
updateHalfEdgeInfo(d, true) ;
Dart stop = m.phi2(vit) ;
assert (stop != vit) ;
Dart vit2 = m.alpha_1(m.phi1(vit)) ;
do {
updateHalfEdgeInfo(vit2, true) ;
updateHalfEdgeInfo(m.phi2(vit2), true) ;
d = m.phi2(vit2) ;
if (d != vit2) ;
updateHalfEdgeInfo(d, true) ;
updateHalfEdgeInfo(m.phi1(vit2), false) ;
updateHalfEdgeInfo(m.phi2(m.phi1(vit2)), false) ;
vit2 = m.alpha_1(vit2) ;
d = m.phi2(m.phi1(vit2)) ;
if (d != m.phi1(vit2)) ;
updateHalfEdgeInfo(d, false) ;
vit2 = m.alpha_1(vit2) ;
} while (stop != vit2) ;
vit = m.alpha1(vit) ;
} while(vit != d2) ;
......@@ -251,7 +264,7 @@ template <typename PFP>
void HalfEdgeSelector_QEMml<PFP>::computeHalfEdgeInfo(Dart d, HalfEdgeInfo& heinfo)
{
MAP& m = this->m_map ;
Dart dd = m.phi2(d) ;
Dart dd = m.phi1(d) ;
Quadric<REAL> quad ;
quad += quadric[d] ; // compute the sum of the
......@@ -288,12 +301,12 @@ bool HalfEdgeSelector_Lightfield<PFP>::init()
}
else if( ok == 1 && (*it)->getApproximatedAttributeName() == "frame")
{
m_frameApproximator = reinterpret_cast<Approximator<PFP, FRAME>* >(*it) ; // 2) frame (needs position)
m_frameApproximator = reinterpret_cast<Approximator<PFP, MATRIX33>* >(*it) ; // 2) frame (needs position)
++ok ;
}
else if(ok == 2 && (*it)->getApproximatedAttributeName() == "colorPTM")
{
m_RGBfunctionsApproximator = reinterpret_cast<Approximator<PFP, RGBFUNCTIONS>* >(*it) ; // 3) functions (needs frame)
m_RGBfunctionsApproximator = reinterpret_cast<Approximator<PFP, MATRIX36>* >(*it) ; // 3) functions (needs frame)
++ok ;
}
}
......@@ -409,8 +422,6 @@ void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool
if (dBack != dFront) { // if dFront is no border
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi1(dFront)],this->m_position[dBack]) ;
if (isnan(this->m_position[d][0]))
std::cout << "NaaaaN" << std::endl ;
}
if (recomputeNeighbors)
recomputeQuadric(dBack, false) ;
......@@ -429,23 +440,35 @@ void HalfEdgeSelector_Lightfield<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
do
{
updateHalfEdgeInfo(vit, true) ;
updateHalfEdgeInfo(m.phi2(vit), true) ;
Dart d = m.phi2(vit) ;
if (d != vit) ;
updateHalfEdgeInfo(d, true) ;
updateHalfEdgeInfo(m.phi1(vit), true) ;
updateHalfEdgeInfo(m.phi2(m.phi1(vit)), true) ;
d = m.phi2(m.phi1(vit)) ;
if (d != m.phi1(vit)) ;
updateHalfEdgeInfo(d, true) ;
Dart stop = m.phi2(vit) ;
assert (stop != vit) ;
Dart vit2 = m.alpha_1(m.phi1(vit)) ;
do {
updateHalfEdgeInfo(vit2, true) ;
updateHalfEdgeInfo(m.phi2(vit2), true) ;
d = m.phi2(vit2) ;
if (d != vit2) ;
updateHalfEdgeInfo(d, true) ;
updateHalfEdgeInfo(m.phi1(vit2), false) ;
updateHalfEdgeInfo(m.phi2(m.phi1(vit2)), false) ;
vit2 = m.alpha_1(vit2) ;
d = m.phi2(m.phi1(vit2)) ;
if (d != m.phi1(vit2)) ;
updateHalfEdgeInfo(d, false) ;
vit2 = m.alpha_1(vit2) ;
} while (stop != vit2) ;
vit = m.alpha1(vit) ;
} while(vit != d2) ;
cur = halfEdges.begin() ; // set the current edge to the first one
}
......@@ -498,7 +521,7 @@ template <typename PFP>
void HalfEdgeSelector_Lightfield<PFP>::computeHalfEdgeInfo(Dart d, HalfEdgeInfo& heinfo)
{
MAP& m = this->m_map ;
Dart dd = m.phi2(d) ;
Dart dd = m.phi1(d) ;
// New position
Quadric<REAL> quad ;
......
......@@ -216,7 +216,7 @@ template <typename PFP>
void Approximator_RGBfunctions<PFP>::approximate(Dart d)
{
MAP& m = this->m_map ;
Dart dd = m.phi2(d) ; // get the two vertices
Dart dd = m.phi1(d) ; // get the two vertices
// get hypothetical local frames
VEC3 i,n ;
......
......@@ -288,9 +288,8 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
if(good(d) && !markF.isMarked(d))
{
markF.markOrbit(FACE_ORBIT, d) ;
faces.push_back(0);
unsigned int& nbe = faces.back();
Dart e = d;
std::vector<unsigned int> face ;
do
{
if (!markV.isMarked(e))
......@@ -300,11 +299,15 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
markV.mark(e);
}
faces.push_back(tableVertLab[e]);
nbe++;
face.push_back(tableVertLab[e]);
e = map.phi1(e);
} while (e!=d);
nbf++;
} while (e!=d) ;
faces.push_back(face.size()) ;
for (unsigned int i = 0 ; i < face.size() ; ++i)
faces.push_back(face.at(i)) ;
++nbf;
}
}
......@@ -358,7 +361,7 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
out << colorPTM[0][vi][2] << " " << colorPTM[1][vi][2] << " " << colorPTM[2][vi][2] << " " << colorPTM[3][vi][2] << " " << colorPTM[4][vi][2] << " " << colorPTM[5][vi][2] << std::endl ;
}
std::vector<unsigned int>::iterator it = faces.begin();;
std::vector<unsigned int>::iterator it = faces.begin();
while (it != faces.end())
{
unsigned int nbe = *it++;
......
......@@ -43,8 +43,7 @@ public:
typedef Geom::Matrix<3,3,REAL> MATRIX33;
typedef Quadric<REAL> QUADRIC;
typedef MATRIX33 FRAME;
typedef Geom::Matrix<3,6,REAL> RGBFUNCTIONS;
typedef Geom::Matrix<3,6,REAL> MATRIX36;
private:
MATRIX66 A;
......@@ -58,13 +57,13 @@ public:
QuadricRGBfunctions();
QuadricRGBfunctions(int i);
QuadricRGBfunctions(const QuadricRGBfunctions&);
QuadricRGBfunctions(const RGBFUNCTIONS&, const REAL gamma = REAL(0), const REAL alpha = REAL(0)) ;
QuadricRGBfunctions(const MATRIX36&, const REAL gamma = REAL(0), const REAL alpha = REAL(0)) ;
virtual ~QuadricRGBfunctions() {} ;
REAL operator() (const RGBFUNCTIONS&) const;
REAL operator() (const MATRIX36&) const;
bool findOptimizedRGBfunctions(RGBFUNCTIONS& lff) const;
bool findOptimizedRGBfunctions(MATRIX36& lff) const;
void operator += (const QuadricRGBfunctions&) ;
void operator -= (const QuadricRGBfunctions&) ;
......
......@@ -67,11 +67,11 @@ QuadricRGBfunctions<REAL>::QuadricRGBfunctions(const QuadricRGBfunctions& q) {
}
template <typename REAL>
QuadricRGBfunctions<REAL>::QuadricRGBfunctions(const RGBFUNCTIONS& cf, const REAL gamma, const REAL alpha) {
QuadricRGBfunctions<REAL>::QuadricRGBfunctions(const MATRIX36& cf, const REAL gamma, const REAL alpha) {
MATRIX66 R1,R2_b,R2_c ;
buildRotateMatrix(R1,gamma); // Rotation 1
R1.transpose() ;
// R1.transpose() ;
buildIntegralMatrix_A(A,alpha); // Parameterized integral matrix A
buildIntegralMatrix_b(R2_b,alpha); // Parameterized integral matrix b
......@@ -92,7 +92,7 @@ QuadricRGBfunctions<REAL>::QuadricRGBfunctions(const RGBFUNCTIONS& cf, const REA
}
template <typename REAL>
REAL QuadricRGBfunctions<REAL>::operator() (const RGBFUNCTIONS& cf) const {
REAL QuadricRGBfunctions<REAL>::operator() (const MATRIX36& cf) const {
REAL res = REAL(0);
for (unsigned col = RED; col < BLUE+1; ++col) {
......@@ -112,7 +112,7 @@ REAL QuadricRGBfunctions<REAL>::operator() (const RGBFUNCTIONS& cf) const {
}
template <typename REAL>
bool QuadricRGBfunctions<REAL>::findOptimizedRGBfunctions(RGBFUNCTIONS& cf) const {
bool QuadricRGBfunctions<REAL>::findOptimizedRGBfunctions(MATRIX36& cf) const {
MATRIX66 Ainv ;
REAL det = A.invert(Ainv) ; // Invert matrix
......
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