Commit 23fbb587 authored by CGoGN GIT Supervisor's avatar CGoGN GIT Supervisor

Merge branch 'master' of /home/vanhoey/CGoGN

* 'master' of /home/vanhoey/CGoGN:
  correction on colourconverter (lost in last pull from master)
  shaderPTM moved to apps
  shader for PTM and import/export for PTM of superior degrees
  some includes added (cgognstream)
  Correction petite erreur (nom lib) dans README Ajout du include cgognStream dans quadricRGBfunctions.h
parents 2dbc138a 45b2b564
......@@ -108,8 +108,6 @@ void MyQT::cb_initGL()
shader1->setAttributePosition(positionVBO);
shader1->setAttributeNormal(normalVBO);
registerShader(shader1);
currentShader = shader1;
}
......
Dépendences Linux:
installer les paquets suivants:
<<<<<<< HEAD
cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev libzip-dev libqt4-help qt4-designer qt4-dev-tools
=======
cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev lizip-dev libqt4-dev qt4-designer qt4-dev-tools
>>>>>>> 84fe346d20a65b08cb049bffc98c793c70f687f2
Pour compiler CGoGN:
......
......@@ -247,6 +247,154 @@ bool exportCTM(typename PFP::MAP& the_map, const typename PFP::TVEC3& position,
return true ;
}
template <typename PFP>
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[15], 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) ;
Dart e = d;
std::vector<unsigned int> face ;
do
{
if (!markV.isMarked(e))
{
vertices.push_back(map.getEmbedding(e, VERTEX_ORBIT));
tableVertLab[e] = lab++;
markV.mark(e);
}
face.push_back(tableVertLab[e]);
e = map.phi1(e);
} while (e!=d) ;
faces.push_back(face.size()) ;
for (unsigned int i = 0 ; i < face.size() ; ++i)
faces.push_back(face.at(i)) ;
++nbf;
}
}
out << "ply" << std::endl ;
out << "format ascii 1.0" << std::endl ;
out << "comment ply PTM" << 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_a0" << std::endl ;
out << "property float L1_a1" << std::endl ;
out << "property float L1_a2" << std::endl ;
out << "property float L1_a3" << std::endl ;
out << "property float L1_a4" << std::endl ;
out << "property float L1_a5" << std::endl ;
out << "property float L1_a6" << std::endl ;
out << "property float L1_a7" << std::endl ;
out << "property float L1_a8" << std::endl ;
out << "property float L1_a9" << std::endl ;
out << "property float L1_a10" << std::endl ;
out << "property float L1_a11" << std::endl ;
out << "property float L1_a12" << std::endl ;
out << "property float L1_a13" << std::endl ;
out << "property float L1_a14" << std::endl ;
out << "property float L2_a0" << std::endl ;
out << "property float L2_a1" << std::endl ;
out << "property float L2_a2" << std::endl ;
out << "property float L2_a3" << std::endl ;
out << "property float L2_a4" << std::endl ;
out << "property float L2_a5" << std::endl ;
out << "property float L2_a6" << std::endl ;
out << "property float L2_a7" << std::endl ;
out << "property float L2_a8" << std::endl ;
out << "property float L2_a9" << std::endl ;
out << "property float L2_a10" << std::endl ;
out << "property float L2_a11" << std::endl ;
out << "property float L2_a12" << std::endl ;
out << "property float L2_a13" << std::endl ;
out << "property float L2_a14" << std::endl ;
out << "property float L3_a0" << std::endl ;
out << "property float L3_a1" << std::endl ;
out << "property float L3_a2" << std::endl ;
out << "property float L3_a3" << std::endl ;
out << "property float L3_a4" << std::endl ;
out << "property float L3_a5" << std::endl ;
out << "property float L3_a6" << std::endl ;
out << "property float L3_a7" << std::endl ;
out << "property float L3_a8" << std::endl ;
out << "property float L3_a9" << std::endl ;
out << "property float L3_a10" << std::endl ;
out << "property float L3_a11" << std::endl ;
out << "property float L3_a12" << std::endl ;
out << "property float L3_a13" << std::endl ;
out << "property float L3_a14" << 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 << 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] << " " << colorPTM[6][vi][0] << " " << colorPTM[7][vi][0] << " " << colorPTM[8][vi][0] << " " << colorPTM[9][vi][0] << " " << colorPTM[10][vi][0] << " " << colorPTM[11][vi][0] << " " << colorPTM[12][vi][0] << " " << colorPTM[13][vi][0] << " " << colorPTM[14][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] << " " << colorPTM[6][vi][1] << " " << colorPTM[7][vi][1] << " " << colorPTM[8][vi][1] << " " << colorPTM[9][vi][1] << " " << colorPTM[10][vi][1] << " " << colorPTM[11][vi][1] << " " << colorPTM[12][vi][1] << " " << colorPTM[13][vi][1] << " " << colorPTM[14][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] << " " << colorPTM[6][vi][2] << " " << colorPTM[7][vi][2] << " " << colorPTM[8][vi][2] << " " << colorPTM[9][vi][2] << " " << colorPTM[10][vi][2] << " " << colorPTM[11][vi][2] << " " << colorPTM[12][vi][2] << " " << colorPTM[13][vi][2] << " " << colorPTM[14][vi][2] << 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 ;
}
/*
template <typename PFP>
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)
{
......@@ -365,7 +513,7 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
out.close() ;
return true ;
}
}*/
} // namespace Export
......
......@@ -529,6 +529,137 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector<
template <typename PFP>
bool MeshTablesSurface<PFP>::importPlyPTM(const std::string& filename, std::vector<std::string>& attrNames)
{
AttributeHandler<typename PFP::VEC3> positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "position") ;
attrNames.push_back(positions.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[15] ;
colorPTM[0] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a0") ;
colorPTM[1] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a1") ;
colorPTM[2] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a2") ;
colorPTM[3] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a3") ;
colorPTM[4] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a4") ;
colorPTM[5] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a5") ;
colorPTM[6] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a6") ;
colorPTM[7] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a7") ;
colorPTM[8] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a8") ;
colorPTM[9] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a9") ;
colorPTM[10] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a10") ;
colorPTM[11] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a11") ;
colorPTM[12] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a12") ;
colorPTM[13] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a13") ;
colorPTM[14] = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a14") ;
for (unsigned int i = 0 ; i < 15 ; ++i)
attrNames.push_back(colorPTM[i].name()) ;
AttributeContainer& container = m_map.getAttributeContainer(VERTEX_CELL) ;
std::ifstream fp(filename.c_str(), std::ios::binary);
if (!fp.good())
{
std::cerr << "Unable to open file " << filename<< std::endl;
return false;
}
std::string ligne;
std::string tag;
fp >> tag;
if (tag != std::string("ply"))
{
std::cerr <<filename<< " is not a ply file !" << std::endl;
return false;
}
// va au nombre de sommets
do
{
fp >> tag;
} while (tag != std::string("vertex"));
unsigned int nbp;
fp >> nbp;
// read points
std::vector<unsigned int> verticesID;
verticesID.reserve(nbp);
// va au nombre de faces en comptant le nombre de "property"
unsigned int nb_props = 0;
do
{
fp >> tag;
if (tag == std::string("property"))
nb_props++;
} while (tag != std::string("face"));
fp >> m_nbFaces;
m_nbEdges.reserve(m_nbFaces);
m_emb.reserve(3*m_nbFaces);
// lecture des sommets
// saute à la fin du header
do
{
fp >> tag;
} while (tag != std::string("end_header"));
float* properties = new float[nb_props];
for (unsigned int i = 0; i < nbp; ++i)
{
unsigned int id = container.insertLine();
verticesID.push_back(id);
for (unsigned int j = 0; j < nb_props; ++j)
{
fp >> properties[j];
}
positions[id] = VEC3(properties[0],properties[1],properties[2]);
for (unsigned int k = 0 ; k < 3 ; ++k)
for (unsigned int l = 0 ; l < 3 ; ++l)
frame[k][id][l] = properties[3+(3*k+l)] ;
for (unsigned int k = 0 ; k < 3 ; ++k)
for (unsigned int l = 0 ; l < 15 ; ++l)
colorPTM[l][id][k] = properties[12+(15*k+l)];
}
m_nbVertices = verticesID.size();
delete[] properties;
// read indices of faces
for (unsigned int i = 0; i < m_nbFaces; i++)
{
// read the indices vertices of face
int nbe;
fp >> nbe;
m_nbEdges.push_back(nbe);
int pt;
for (int j=0; j<nbe; ++j)
{
fp >> pt;
m_emb.push_back(verticesID[pt]);
}
}
fp.close();
return true;
}
/*template <typename PFP>
bool MeshTablesSurface<PFP>::importPlyPTM(const std::string& filename, std::vector<std::string>& attrNames)
{
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "position") ;
......@@ -651,7 +782,7 @@ bool MeshTablesSurface<PFP>::importPlyPTM(const std::string& filename, std::vect
fp.close();
return true;
}
}*/
template <typename PFP>
bool MeshTablesSurface<PFP>::importCTM(const std::string& filename, std::vector<std::string>& attrNames)
......
......@@ -316,6 +316,6 @@ public:
} // namespace CGoGN
#include "Algo/Render/vbo_MapRender.hpp"
#include "Algo/Render/Deprecated/vbo_MapRender.hpp"
#endif
......@@ -27,6 +27,7 @@
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Utils/cgognStream.h"
namespace CGoGN {
......@@ -38,8 +39,8 @@ namespace Utils {
enum ColourEncoding
{
C_RGB = 0,
C_Luv = 1,
C_XYZ = 2,
C_XYZ = 1,
C_Luv = 2,
C_Lab = 3
} ;
......
......@@ -28,6 +28,7 @@
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Utils/cgognStream.h"
using namespace CGoGN;
......
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