Commit 49e7e333 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

passed to new container format for plyptm : good for glsl (only vec3)

parent 195e3fc5
......@@ -44,6 +44,7 @@ enum ApproximatorType
A_CornerCutting,
A_TangentPredict1,
A_TangentPredict2,
A_LightfieldHalf,
A_LightfieldFull
} ;
......
......@@ -71,11 +71,11 @@ void decimate(
}
case A_LightfieldHalf :
{
approximators.push_back(new Approximator_QEM<PFP>(map, position)) ;
approximators.push_back(new Approximator_HalfCollapse<PFP>(map, position)) ;
AttributeHandler<Geom::Matrix<3,3,typename PFP::REAL> > frame = map.template getAttribute<Geom::Matrix<3,3,typename PFP::REAL> >(VERTEX_ORBIT, "frame") ;
AttributeHandler<Geom::Matrix<3,6,typename PFP::REAL> > RGBfunctions = map.template getAttribute<Geom::Matrix<3,6,typename PFP::REAL> >(VERTEX_ORBIT, "colorPTM") ;
approximators.push_back(new Approximator_FrameHalf<PFP>(map, frame)) ;
approximators.push_back(new Approximator_RGBfunctions<PFP>(map, RGBfunctions)) ;
approximators.push_back(new Approximator_RGBfunctionsHalf<PFP>(map, RGBfunctions)) ;
break ;
}
}
......@@ -91,12 +91,18 @@ void decimate(
case S_EdgeLength :
selector = new EdgeSelector_Length<PFP>(map, position, approximators) ;
break ;
case S_QEMml :
selector = new EdgeSelector_QEMml<PFP>(map, position, approximators) ;
break ;
case S_QEM :
selector = new EdgeSelector_QEM<PFP>(map, position, approximators) ;
break ;
case S_Lightfield :
selector = new EdgeSelector_Lightfield<PFP>(map, position, approximators) ;
break ;
case S_LightfieldHalf :
selector = new HalfEdgeSelector_Lightfield<PFP>(map, position, approximators) ;
break ;
case S_Curvature :
selector = new EdgeSelector_Curvature<PFP>(map, position, approximators) ;
break ;
......
......@@ -36,6 +36,55 @@ namespace Algo
namespace Decimation
{
template <typename PFP>
class Approximator_FrameHalf : public Approximator<PFP, typename Geom::Matrix<3,3,typename PFP::REAL> >
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
typedef Geom::Matrix<3,3,REAL> MATRIX33 ;
typedef Geom::Matrix<3,6,REAL> MATRIX36 ;
public:
Approximator_FrameHalf(MAP& m, AttributeHandler<MATRIX33>& frame, Predictor<PFP, MATRIX33>* pred = NULL) :
Approximator<PFP, MATRIX33>(m, frame, EDGE_ORBIT, pred)
{}
~Approximator_FrameHalf()
{}
ApproximatorType getType() const { return A_LightfieldHalf ; }
bool init() { return true ; } ;
void approximate(Dart d) ;
} ;
template <typename PFP>
class Approximator_RGBfunctionsHalf : public Approximator<PFP, typename Geom::Matrix<3,6,typename PFP::REAL> >
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
typedef Geom::Matrix<3,3,REAL> MATRIX33 ;
typedef Geom::Matrix<3,6,REAL> MATRIX36 ;
protected:
AttributeHandler<MATRIX33> m_frame ;
AttributeHandler<MATRIX33> m_approxFrame ;
AttributeHandler<QuadricRGBfunctions<REAL> > m_quadricRGBfunctions ;
public:
Approximator_RGBfunctionsHalf(MAP& m, AttributeHandler<MATRIX36>& rgbfunctions, Predictor<PFP, MATRIX36>* pred = NULL) :
Approximator<PFP, MATRIX36>(m, rgbfunctions, EDGE_ORBIT, pred)
{ }
~Approximator_RGBfunctionsHalf ()
{}
ApproximatorType getType() const { return A_LightfieldHalf ; }
bool init() ;
void approximate(Dart d) ;
} ;
template <typename PFP>
class Approximator_Frame : public Approximator<PFP, typename Geom::Matrix<3,3,typename PFP::REAL> >
{
......
......@@ -31,6 +31,96 @@ namespace Algo
namespace Decimation
{
/************************************************************************************
* LIGHTFIELD QUADRIC METRIC : frame *
************************************************************************************/
template <typename PFP>
void Approximator_FrameHalf<PFP>::approximate(Dart d)
{
this->m_approx[d] = this->m_attrV[d] ;
}
/************************************************************************************
* LIGHTFIELD QUADRIC METRIC : functions *
************************************************************************************/
template <typename PFP>
bool Approximator_RGBfunctionsHalf<PFP>::init()
{
// get actual frames and hypothetical approximated frames
m_frame = this->m_map.template getAttribute<MATRIX33>(VERTEX_ORBIT, "frame") ;
m_approxFrame = this->m_map.template getAttribute<MATRIX33>(EDGE_ORBIT, "approx_frame") ;
m_quadricRGBfunctions = this->m_map.template getAttribute<QuadricRGBfunctions<REAL> >(EDGE_ORBIT, "quadricRGBfunctions") ;
MapBrowserLinkedAuto<typename PFP::MAP> mb(this->m_map) ;
this->m_map.foreach_orbit(EDGE_ORBIT, mb) ;
// create quadric embedding for computing and set them to 0
for (Dart d = mb.begin() ; d != mb.end() ; mb.next(d))
m_quadricRGBfunctions[d].zero() ;
// Check on embeddings
if (!m_frame.isValid() || !m_approxFrame.isValid() || !m_quadricRGBfunctions.isValid())
{
std::cerr << "Approximator_RGBfunctions::init() --> No approxPosition or no quadricRGBfunctions specified" << std::endl ;
return false ;
}
return true ;
}
template <typename PFP>
void Approximator_RGBfunctionsHalf<PFP>::approximate(Dart d)
{
MAP& m = this->m_map ;
Dart dd = m.phi2(d) ; // get the two vertices
// Approximation
this->m_approx[d] = this->m_attrV[d] ;
// Compute quadrics for error evaluation
// get hypothetical local frames
VEC3 i,n ;
m_approxFrame[d].getSubVectorH(0,0,i) ;
m_approxFrame[d].getSubVectorH(2,0,n) ;
// Get previous local frames
VEC3 n1,n2,i1,i2,j1,j2 ;
m_frame[d].getSubVectorH(0,0,i1) ;
m_frame[dd].getSubVectorH(0,0,i2) ;
m_frame[d].getSubVectorH(1,0,j1) ;
m_frame[dd].getSubVectorH(1,0,j2) ;
m_frame[d].getSubVectorH(2,0,n1) ;
m_frame[dd].getSubVectorH(2,0,n2) ;
// Compute j1' and j2'
VEC3 j1pr = n1 ^ i ;
j1pr.normalize() ;
VEC3 j2pr = n2 ^ i ;
j2pr.normalize() ;
// Rotation dans sens trigo dans le plan tangent autour de n (i1->i)
// REAL gamma1 = ((j1 * i) > 0 ? 1 : -1) * acos( std::max(std::min(1.0f, i1 * i ), -1.0f)) ; // angle positif ssi
REAL gamma2 = ((j2 * i) > 0 ? 1 : -1) * acos( std::max(std::min(1.0f, i2 * i ), -1.0f)) ; // -PI/2 < angle(i,j1) < PI/2 ssi i*j1 > 0
// Rotation dans le sens trigo autour de l'axe i (n1->n)
// REAL alpha1 = ((n * j1pr) > 0 ? -1 : 1) * acos( std::max(std::min(1.0f, n * n1), -1.0f) ) ; // angle positif ssi
REAL alpha2 = ((n * j2pr) > 0 ? -1 : 1) * acos( std::max(std::min(1.0f, n * n2), -1.0f) ) ; // PI/2 < angle(j1',n) < -PI/2 ssi j1'*n < 0
// assert (-0.01 < gamma1 && gamma1 < 0.01) ;
// assert (-0.01 < alpha1 && alpha1 < 0.01) ;
REAL gamma1 = REAL(0) ;
REAL alpha1 = REAL(0) ;
// Create and sum quadrics
m_quadricRGBfunctions[d] += QuadricRGBfunctions<REAL>(this->m_attrV[d], gamma1, alpha1) ;
m_quadricRGBfunctions[d] += QuadricRGBfunctions<REAL>(this->m_attrV[dd], gamma2, alpha2) ;
}
/************************************************************************************
* LIGHTFIELD QUADRIC METRIC : frame *
************************************************************************************/
......@@ -106,8 +196,11 @@ bool Approximator_RGBfunctions<PFP>::init()
m_approxFrame = this->m_map.template getAttribute<MATRIX33>(EDGE_ORBIT, "approx_frame") ;
m_quadricRGBfunctions = this->m_map.template getAttribute<QuadricRGBfunctions<REAL> >(EDGE_ORBIT, "quadricRGBfunctions") ;
MapBrowserLinkedAuto<typename PFP::MAP> mb(this->m_map) ;
this->m_map.foreach_orbit(EDGE_ORBIT, mb) ;
// create quadric embedding for computing and set them to 0
for (Dart d = this->m_map.begin() ; d != this->m_map.end() ; this->m_map.next(d))
for (Dart d = mb.begin() ; d != mb.end() ; mb.next(d))
m_quadricRGBfunctions[d].zero() ;
// Check on embeddings
......
......@@ -46,9 +46,11 @@ enum SelectorType
S_Random,
S_EdgeLength,
S_QEM,
S_QEMml,
S_MinDetail,
S_Curvature,
S_Lightfield
S_Lightfield,
S_LightfieldHalf
} ;
......@@ -228,6 +230,120 @@ public:
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_QEMml : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "QEMedgeInfo" ; }
} QEMedgeInfo ;
typedef NoMathIOAttribute<QEMedgeInfo> EdgeInfo ;
AttributeHandler<EdgeInfo> edgeInfo ;
AttributeHandler<Quadric<REAL> > quadric ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
void recomputeQuadric(const Dart d, const bool neighbours = false) ;
Dart rewind(const Dart d) ;
public:
EdgeSelector_QEMml(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
edgeInfo = m.template addAttribute<EdgeInfo>(EDGE_ORBIT, "edgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL> >(VERTEX_ORBIT, "QEMquadric") ;
}
~EdgeSelector_QEMml()
{
this->m_map.removeAttribute(quadric) ;
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_QEM ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class HalfEdgeSelector_Lightfield : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
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
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "LightfieldHalfEdgeInfo" ; }
} LightfieldHalfEdgeInfo ;
typedef NoMathIOAttribute<LightfieldHalfEdgeInfo> HalfEdgeInfo ;
AttributeHandler<FRAME > m_frame ;
AttributeHandler<HalfEdgeInfo> halfEdgeInfo ;
AttributeHandler<Quadric<REAL> > quadric ;
AttributeHandler<QuadricRGBfunctions<REAL> > quadricRGBfunctions ;
std::multimap<float,Dart> halfEdges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, VEC3>* m_positionApproximator ;
Approximator<PFP, FRAME >* m_frameApproximator ;
Approximator<PFP, RGBFUNCTIONS >* m_RGBfunctionsApproximator ;
void initHalfEdgeInfo(Dart d) ;
void updateHalfEdgeInfo(Dart d, bool recompute) ;
void computeHalfEdgeInfo(Dart d, HalfEdgeInfo& einfo) ;
void recomputeQuadric(const Dart d, const bool neighbors) ;
Dart rewind(const Dart d) ;
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") ;
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo>(DART_ORBIT, "halfEdgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL> >(VERTEX_ORBIT, "QEMquadric") ;
quadricRGBfunctions = m.template addAttribute<QuadricRGBfunctions<REAL> >(EDGE_ORBIT, "quadricRGBfunctions") ;
}
~HalfEdgeSelector_Lightfield()
{
this->m_map.removeAttribute(quadric) ;
this->m_map.removeAttribute(quadricRGBfunctions) ;
this->m_map.removeAttribute(halfEdgeInfo) ;
}
SelectorType getType() { return S_Lightfield ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_Lightfield : public EdgeSelector<PFP>
{
......
This diff is collapsed.
......@@ -76,22 +76,13 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position,
* export the map into a PLYPTM file
* @param the_map map to be exported
* @param filename filename of ply file
* @param position the position container
* @param frame[3] table of 3 vectors representing the local frame
* @param colorPTM[6] function coefficients (6) for each color channel (3)
* @return true
*/
template <typename PFP>
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& Pos,
const typename PFP::TVEC3& Tan, const typename PFP::TVEC3& Btan, const typename PFP::TVEC3& Norm,
const AttributeHandler<typename PFP::VEC6>& L1, AttributeHandler<typename PFP::VEC6>& L2, const AttributeHandler<typename PFP::VEC6>& L3,
const FunctorSelect& good = SelectorTrue()) ;
/**
* export the map into a PLYPTM file
* @param the_map map to be exported
* @param filename filename of ply file
* @return true
*/
template <typename PFP>
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& Pos, const typename PFP::TMAT33& Frame, const typename PFP::TMAT36& RGBfuncs, const FunctorSelect& good = SelectorTrue()) ;
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good = SelectorTrue()) ;
} // namespace Export
......
......@@ -256,7 +256,7 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position,
}
template <typename PFP>
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& Pos, const typename PFP::TMAT33& Frame, const typename PFP::TMAT36& RGBfuncs, const FunctorSelect& good)
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
......@@ -349,13 +349,13 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
for(unsigned int i = 0; i < vertices.size(); ++i)
{
unsigned int vi = vertices[i];
out << Pos[vi][0] << " " << Pos[vi][1] << " " << Pos[vi][2]<<" ";
out << Frame[vi](0,0) << " " << Frame[vi](0,1) << " " << Frame[vi](0,2) << " " ;
out << Frame[vi](1,0) << " " << Frame[vi](1,1) << " " << Frame[vi](1,2) << " " ;
out << Frame[vi](2,0) << " " << Frame[vi](2,1) << " " << Frame[vi](2,2) << " " ;
out << RGBfuncs[vi](0,0) << " " << RGBfuncs[vi](0,1) << " " << RGBfuncs[vi](0,2) << " " << RGBfuncs[vi](0,3) << " " << RGBfuncs[vi](0,4) << " " << RGBfuncs[vi](0,5) <<" ";
out << RGBfuncs[vi](1,0) << " " << RGBfuncs[vi](1,1) << " " << RGBfuncs[vi](1,2) << " " << RGBfuncs[vi](1,3) << " " << RGBfuncs[vi](1,4) << " " << RGBfuncs[vi](1,5) <<" ";
out << RGBfuncs[vi](2,0) << " " << RGBfuncs[vi](2,1) << " " << RGBfuncs[vi](2,2) << " " << RGBfuncs[vi](2,3) << " " << RGBfuncs[vi](2,4) << " " << RGBfuncs[vi](2,5) << std::endl ;
out << position[vi][0] << " " << position[vi][1] << " " << position[vi][2] << " " ;
out << frame[0][vi][0] << " " << frame[0][vi][1] << " " << frame[0][vi][2] << " " ;
out << frame[1][vi][0] << " " << frame[1][vi][1] << " " << frame[1][vi][2] << " " ;
out << frame[2][vi][0] << " " << frame[2][vi][1] << " " << frame[2][vi][2] << " " ;
out << colorPTM[0][vi][0] << " " << colorPTM[1][vi][0] << " " << colorPTM[2][vi][0] << " " << colorPTM[3][vi][0] << " " << colorPTM[4][vi][0] << " " << colorPTM[5][vi][0] <<" " ;
out << colorPTM[0][vi][1] << " " << colorPTM[1][vi][1] << " " << colorPTM[2][vi][1] << " " << colorPTM[3][vi][1] << " " << colorPTM[4][vi][1] << " " << colorPTM[5][vi][1] <<" " ;
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();;
......@@ -372,128 +372,6 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
return true ;
}
template <typename PFP>
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& Pos,
const typename PFP::TVEC3& Tan, const typename PFP::TVEC3& Btan, const typename PFP::TVEC3& Norm,
const AttributeHandler<typename PFP::VEC6>& L1, AttributeHandler<typename PFP::VEC6>& L2, const AttributeHandler<typename PFP::VEC6>& L3,
const FunctorSelect& good)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
std::ofstream out(filename, std::ios::out) ;
if (!out.good())
{
std::cerr << "Unable to open file " << std::endl ;
return false ;
}
AutoAttributeHandler<unsigned int> tableVertLab(map, VERTEX_ORBIT);
CellMarker markV(map,VERTEX_CELL);
unsigned int nbDarts = map.getNbDarts() ;
std::vector<unsigned int> vertices;
std::vector<unsigned int> faces;
vertices.reserve(nbDarts/5); // TODO non optimal reservation
faces.reserve(nbDarts/3);
DartMarker markF(map);
unsigned int lab = 0;
unsigned int nbf = 0;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(good(d) && !markF.isMarked(d))
{
markF.markOrbit(FACE_ORBIT, d) ;
faces.push_back(0);
unsigned int& nbe = faces.back();
Dart e = d;
do
{
if (!markV.isMarked(e))
{
vertices.push_back(map.getEmbedding(e, VERTEX_ORBIT));
tableVertLab[e] = lab++;
markV.mark(e);
}
faces.push_back(tableVertLab[e]);
nbe++;
e = map.phi1(e);
} while (e!=d);
nbf++;
}
}
out << "ply" << std::endl ;
out << "format ascii 1.0" << std::endl ;
out << "comment ply PTM (F. Larue format)" << std::endl ;
out << "element vertex " << vertices.size() << std::endl ;
out << "property float x" << std::endl ;
out << "property float y" << std::endl ;
out << "property float z" << std::endl ;
out << "property float tx" << std::endl ;
out << "property float ty" << std::endl ;
out << "property float tz" << std::endl ;
out << "property float bx" << std::endl ;
out << "property float by" << std::endl ;
out << "property float bz" << std::endl ;
out << "property float nx" << std::endl ;
out << "property float ny" << std::endl ;
out << "property float nz" << std::endl ;
out << "property float L1_a" << std::endl ;
out << "property float L1_b" << std::endl ;
out << "property float L1_c" << std::endl ;
out << "property float L1_d" << std::endl ;
out << "property float L1_e" << std::endl ;
out << "property float L1_f" << std::endl ;
out << "property float L2_a" << std::endl ;
out << "property float L2_b" << std::endl ;
out << "property float L2_c" << std::endl ;
out << "property float L2_d" << std::endl ;
out << "property float L2_e" << std::endl ;
out << "property float L2_f" << std::endl ;
out << "property float L3_a" << std::endl ;
out << "property float L3_b" << std::endl ;
out << "property float L3_c" << std::endl ;
out << "property float L3_d" << std::endl ;
out << "property float L3_e" << std::endl ;
out << "property float L3_f" << std::endl ;
out << "element face " << nbf << std::endl ;
out << "property list uchar int vertex_indices" << std::endl ;
out << "end_header" << std::endl ;
for(unsigned int i = 0; i < vertices.size(); ++i)
{
unsigned int vi = vertices[i];
out << Pos[vi][0] << " " << Pos[vi][1] << " " << Pos[vi][2]<<" ";
out << Tan[vi][0] << " " << Tan[vi][1] << " " << Tan[vi][2]<<" ";
out << Btan[vi][0] << " " << Btan[vi][1] << " " << Btan[vi][2]<<" ";
out << Norm[vi][0] << " " << Norm[vi][1] << " " << Norm[vi][2]<<" ";
out << L1[vi][0] << " " << L1[vi][1] << " " << L1[vi][2]<< " " << L1[vi][3] << " " << L1[vi][4] << " " << L1[vi][5] <<" ";
out << L2[vi][0] << " " << L2[vi][1] << " " << L2[vi][2]<< " " << L2[vi][3] << " " << L2[vi][4] << " " << L2[vi][5] <<" ";
out << L3[vi][0] << " " << L3[vi][1] << " " << L3[vi][2]<< " " << L3[vi][3] << " " << L3[vi][4] << " " << L3[vi][5] << std::endl ;
}
std::vector<unsigned int>::iterator it = faces.begin();;
while (it != faces.end())
{
unsigned int nbe = *it++;
out << nbe ;
for(unsigned int j = 0; j < nbe; ++j)
out << " " << *it++;
out << std::endl ;
}
out.close() ;
return true ;
}
} // namespace Export
} // namespace Algo
......
......@@ -512,10 +512,24 @@ bool MeshTablesSurface<PFP>::importPlyPTM(const std::string& filename, std::vect
{
AttributeHandler<typename PFP::VEC3> positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "position") ;
attrNames.push_back(positions.name()) ;
AttributeHandler<typename PFP::MATRIX33> Frame = m_map.template addAttribute<typename PFP::MATRIX33>(VERTEX_ORBIT, "frame") ;
attrNames.push_back(Frame.name()) ;
AttributeHandler<typename PFP::MATRIX36> RGBfunctions = m_map.template addAttribute<typename PFP::MATRIX36>(VERTEX_ORBIT, "colorPTM") ;
attrNames.push_back(RGBfunctions.name()) ;
AttributeHandler<typename PFP::VEC3> frame[3] ;
frame[0] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "frame_T") ; // Tangent
frame[1] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "frame_B") ; // Bitangent
frame[2] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "frame_N") ; // Normal
for (unsigned int i = 0 ; i < 3 ; ++i)
attrNames.push_back(frame[i].name()) ;
AttributeHandler<typename PFP::VEC3> colorPTM[6] ;
colorPTM[0] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a") ;
colorPTM[1] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_b") ;
colorPTM[2] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_c") ;
colorPTM[3] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_d") ;
colorPTM[4] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_e") ;
colorPTM[5] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_f") ;
for (unsigned int i = 0 ; i < 6 ; ++i)
attrNames.push_back(colorPTM[i].name()) ;
AttributeContainer& container = m_map.getAttributeContainer(VERTEX_CELL) ;
......@@ -585,11 +599,11 @@ bool MeshTablesSurface<PFP>::importPlyPTM(const std::string& filename, std::vect
for (unsigned int k = 0 ; k < 3 ; ++k)
for (unsigned int l = 0 ; l < 3 ; ++l)
Frame[id](k,l) = properties[3+(3*k+l)] ;
frame[k][id][l] = properties[3+(3*k+l)] ;
for (unsigned int k = 0 ; k < 3 ; ++k)
for (unsigned int l = 0 ; l < 6 ; ++l)
RGBfunctions[id](k,l) = properties[12+(6*k+l)];
colorPTM[l][id][k] = properties[12+(6*k+l)];
}
m_nbVertices = verticesID.size();
......
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